我有一个UIViewController与其中的两个UITableView的。当我在第一个UITableView中选择一行时,它必须推送相同的UIViewController,这不会发生。pushViewController不工作,即使我有一个导航控制器
在UIViewController.h我有,
FirstTableViewController *firstController;
SecondTableViewController *secondController;
在UIViewController.m我有,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if (firstController == nil) {
firstController = [[FirstTableViewController alloc] init];
}
if (secondController == nil) {
secondController = [[SecondTableViewController alloc] init];
}
UINavigationController *firstNavigationController = [[UINavigationController alloc] initWithRootViewController:firstController];
firstController.product = self.product;
[firstTable setDataSource:firstController];
[firstTable setDelegate:firstController];
firstNavigationController.view = firstController.tableView;
}
在FirstTableViewController.m,didSelectRowAtIndexPath方法我有,
[self.searchDisplayController setActive:YES animated:YES];
UIViewController *controller = [[UIViewController alloc]initWithNibName:@"UIViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
controller.product = prod;
NSLog(@"Navigation controller is %@",self.navigationController); //not null
[[self navigationController]pushViewController:controller animated:YES];
请帮助。编辑#1:UIViewController从UtilityApp的FlipsideViewController调用。
'[self navigationController]'返回'nil'? – dasblinkenlight
不,它返回 –