关于NavigationController的一个问题。

以下是我的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>

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

阅读 3.7k
2 个回答

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];
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题