Code Bye

navigationViewController 设置rootViewController

 

调用的代码

    [self loadViewByLoginCondition];
    
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
    return YES;

函数的代码:

- (void)loadViewByLoginCondition{

    if (![NSString isNullOrEmpty:self.tokenKey] && ![NSString isNullOrEmpty:self.tokenSecret]) {
        
        PublishContentController *publishContentController 
            = [[PublishContentController alloc] initWithNibName:@"PublishContentController" bundle:nil];
        self.viewController = publishContentController;
    }
    else{
        
        WeiboWebviewController *authController 
            = [[WeiboWebviewController alloc] initWithNibName:@"WeiboWebviewController" bundle:nil];
        self.viewController = authController;
    }
    
    [navigationController initWithRootViewController:self.viewController];
}

设置这个root view controller不管用。怎么回事?


10分
你好~
把 “self”去掉看看~

10分
[self.navigationController pushViewController:self.viewController];

20分
navigationController中的各个视图并不是add上去的.是一个一个推进去的.
比如你当前有个tableView其中自然就带了一个navigationController
想要添加的下级视图名字叫myViewController就这样写
[self.navigationController pushViewController:self.myViewController animated:YES];

当然,不是上来就推进去的.是在响应一定条件后的比如
if(触摸按钮)
   推入下级视图


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明navigationViewController 设置rootViewController