您的位置:首页 > 移动开发 > IOS开发

ios pushViewController 页面不跳转问题解决

2017-07-18 17:58 661 查看
挺长时间没写iOS代码了,今天在写页面跳转的时候发现跳转不了,代码是这样的:

-(void)pushClick:(UIButton*)sender{
SecondViewController *secondVC = [[SecondViewController alloc]init];
secondVC.labelString = _textLabel.text;
[self.navigationController pushViewController:secondVC animated:YES];
}


这是因为我们默认采用的mainstory启动,当换了viewcontroller启动时,navigationController为空。

所以需要在AppDelegate.m启动中添加:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
FirstViewController *fc = [[FirstViewController alloc]init];
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:fc];
[self.window setRootViewController:navCtrlr];
//navCtrlr.navigationBarHidden = YES;
return YES;
}
这样页面就能跳转了,但是问题是页面都是黑的啊,解决方案是
self.view.backgroundColor = [UIColor whiteColor];
这样就OK了。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 页面跳转问题