0
点赞
收藏
分享

微信扫一扫

ios pushViewController 无效果


当我们第一次实现页面跳转时,发现使用

-(void)pushButtonPressed:(UIButton*)sender{
NSLog(@"dsfas");
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 {
// Override point for customization after application launch.
FirstViewController *fc = [[FirstViewController alloc]init];
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:fc];
[self.window setRootViewController:navCtrlr];
navCtrlr.navigationBarHidden = YES;
return YES;
}


举报

相关推荐

0 条评论