【发布时间】:2018-09-12 08:58:37
【问题描述】:
我在另一个名为 ViewController 的视图中使用 UITableView 作为 childView,在 UITableView 中,我希望单元格可以点击并导航到destinationView,而不使用storyBoard,所以我在didSelectRowAtIndexPath 上实现了这段代码
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"helloWorld!");
DescriptionViewController *desc = [[DescriptionViewController alloc]
initWithNibName:@"DescriptionViewController" bundle:nil];
[self.navigationController pushViewController:desc animated:YES];
}
【问题讨论】:
-
既然你没有使用 Storyboards,你确定你已经正确设置了父 UINavigationController 吗?这将有助于显示导航控制器的代码。
-
检查 self.navigationController 是否为零?
-
self.navigationController 返回 nil
-
试试 [self.parentViewController.navigationController pushViewController:desc animated:YES];
标签: ios objective-c uitableview