【问题标题】:xcode: How to add a UINavigationController to a view controller which is different main view controller?xcode:如何将 UINavigationController 添加到与主视图控制器不同的视图控制器?
【发布时间】:2012-11-28 10:14:29
【问题描述】:

我有 3 个视图控制器:view1、view2、view3,其中 view1 是主视图。 从 view1 我使用 presentModalViewController 来调用 view2。

从 view2 我想使用导航控制器来调用 view3。我怎样才能做到这一点? 我可以使用 UINavigationController 创建像 appDelegate 这样的 view2Delegate 类吗?如何使用连接view2和view2Delegate来使用view2Delegate的导航控制器?

提前致谢。

【问题讨论】:

    标签: xcode controller navigation


    【解决方案1】:

    如下所示将 View2 呈现为模态视图控制器。

    View2 *view2 = [[View2 alloc] initWithNibName:@"View2" bundle:nil];
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:View2];
    [self presentModalViewController:navController animated:YES];
    

    然后在View2中,添加如下代码推送View3

    View3 *view3 = [[View3 alloc] initWithNibName:@"View3" bundle:nil];
    [self.navigationController pushViewController:view3 animated:YES];
    

    【讨论】:

    • 感谢您的回答,但我尝试遵循您的建议,但仍无法填充 view3。
    猜你喜欢
    • 2013-10-15
    • 2014-05-23
    • 2016-01-03
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    • 2013-06-05
    • 2023-03-11
    • 1970-01-01
    相关资源
    最近更新 更多