我有三个视图控制器A,B,C。我将导航控制器连接到A视图控制器。在A中,我有一些按钮,我将按钮segue附加到了B视图控制器。单击按钮后,我转到了B视图控制器在B View控制器上,单击表视图项时我有UITableView,我正在启动C视图控制器。以下是该代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
{
NSLog(@"first cell");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"BusinessCard"];
[self presentViewController:vc animated:YES completion:nil];
}
else if(indexPath.row==1)
{
NSLog(@"second cell");
}
else if(indexPath.row==2)
{
NSLog(@"third cell");
}
}
但是在C视图控制器上没有出现导航栏。我认为C视图控制器未链接到导航控制器。
您使用navigationController
push方法在C viewController中显示导航栏
试试这个代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"BusinessCard"];
[self.navigationController pushViewController:vc animated:YES];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句