开发者社区> 问答> 正文

关于添加UINavigationController 的问题

如果给UIViewController添加作为modalUINavigationController

有一个flow,在firstViewController中开始,然后在view中调用secondViewController

- (IBAction)PressButton:(id)sender {

    SecondViewController *second = [[SecondViewController alloc] init];
    second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    UINavigationController *nav = self.navigationController;
    [nav presentViewController:second animated:YES completion:nil];                              
}

secondViewController 中希望能推进thirdViewController,但是没有用,我用了下面的方法尝试:

- (IBAction)pressButton:(id)sender {

   ThirdViewController *tvc = [[ThirdViewController alloc] init];
   UINavigationController *nav = self.navigationController;
   [nav pushViewController:tvc animated:YES];
}

点击 secondViewController 时完全没有反应。

请高手指点一下哪里出错了,谢谢
我用的:

 OSX 10.8.2
 Xcode 4.6
 iOS 6.1

展开
收起
爵霸 2016-03-24 11:57:45 1717 0
1 条回答
写回答
取消 提交回答
  • 将第二个view作为导航控制器的root,同时从所属的view中调用当前ViewController

    - (IBAction)PressButton:(id)sender {
            SecondViewController *second = [[SecondViewController alloc] init];
            second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
            UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:second];
            [self presentViewController:navigationController animated:YES completion:nil];    
        }
    2019-07-17 19:12:33
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载