HI
Я работаю над проектом на основе UITablview. Мне нравится загружать новый вид, когда когда-либо ячейка получила щелчок. Я использую следующий код в методе didselectRowAtIndexPath делегата.
Приведенная ниже кодировка не отображает никаких ошибок, но новое представление не загружается, и [self navigationController] возвращает ноль.
внутри функции Viewdidload [self navigationcontroller], возвращающей правильное значение. но внутри метода Delegate [self navigationcontroller] возвращается значение null.
/// inside appDelegate class
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.viewController = [[LAMainViewController_iPhone alloc]initWithNibName:@"LAMainViewController_iPhone" bundle:nil];
UINavigationController *controller = [[UINavigationController alloc]initWithRootViewController:viewController];
[window addSubview:controller.view];
[controller release];
[window makeKeyAndVisible];
return YES;
}
/// inside LAmainviewcontroller.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
//self.navigationController.navigationBar.backgroundColor =[UIColor clearColor];// .title=@"test";
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *materialPlistPath = [[NSBundle mainBundle]pathForResource:@"materials" ofType:@"plist"];
materialList = [[NSArray alloc]initWithContentsOfFile:materialPlistPath];
materialTable.backgroundColor = [UIColor blackColor];
NSLog(@" dud kiad navigationController %@", self.navigationController);
//2010-10-20 15:22:03.809 LabAssistant[17368:207] dud kiad navigationController <UINavigationController: 0x5f3b160>
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
self.navigationController.navigationBarHidden = YES;
NSIndexPath *indexPath = [materialTable indexPathForSelectedRow];
[materialTable deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
LAMaterialPropertiesViewController_iPhone *materialPropertyListView = [[[LAMaterialPropertiesViewController_iPhone alloc] initWithNibName:@"LAMaterialPropertiesViewController_iPhone" bundle:nil] autorelease];
materialPropertyListView.chemicalName = [[materialList objectAtIndex:[indexPath row]] objectForKey:@"materialProperty"];
[[self navigationController] pushViewController:materialPropertyListView animated:YES];
NSLog(@"%@",[self navigationController]);
///2010-10-20 16:20:42.634 LabAssistant[17656:207] navigationController (null)
}
, пожалуйста, помогите мне решить эту проблему.
спасибо!