ios - 关于NavigationController的一个问题。
ringa_lee
ringa_lee 2017-04-17 17:24:13
[iOS讨论组]

以下是我的AppDelegate.m代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    MenuViewController *leftVC = [[MenuViewController alloc] init];
    StatusViewController *plainVC = [[StatusViewController alloc] init];
    ICSDrawerController *drawer = [[ICSDrawerController alloc] initWithLeftViewController: leftVC centerViewController: plainVC];
    
    self.window.rootViewController = drawer;
    navController = [[UINavigationController alloc] initWithRootViewController: drawer];
    [self.window makeKeyAndVisible];
    
    return YES;
}

其中,ICSDrawerController中包括两个成员MenuViewControllerStatusController。在StatusController.m中,我想令其在触发按钮后跳转进入另外一个界面,部分代码如下:

- (IBAction) startToRunning: (id)sender {
    NSLog (@"hello");
    RunningViewController *RVC = [[RunningViewController alloc] init];
    [self.navigationController pushViewController: RVC animated: true];
    NSLog(@"%@", self.navigationController);
}

在实测中的console输出:

2016-01-18 11:00:18.043 SunnySports[11582:1035035] hello
2016-01-18 11:00:18.043 SunnySports[11582:1035035] <UINavigationController: 0x7fc71181da00>

但是,界面却无法跳转。求助!!

ringa_lee
ringa_lee

ringa_lee

全部回复(2)
ringa_lee

self.window.rootViewController = drawer;

这句话改为

self.window.rootViewController = navController

并且写在 [self.window makeKeyAndVisible]; 的上面试试

天蓬老师
self.window.rootViewController = drawer;//这句话去掉
    navController = [[UINavigationController alloc] initWithRootViewController: drawer];
    self.window.rootViewController = navController;//这里加上试试
    [self.window makeKeyAndVisible];
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号