Why is my new view controller not appearing?

2020-04-19 15:05发布

I am using the following code to push my view controller, except when the UIButton is pressed - nothing happens apart from the NSLog statement:

-(IBAction)doChangePasscode{

NSLog(@"Change Passcode Screen Loaded!"); 

ChangePasscode *cpscreen = [[ChangePasscode alloc] initWithNibName:@"ChangePasscode" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:cpscreen animated:YES];

}

I have imported the relavant files (using #import) so everything should be fine...

Why is this happening?

Thanks!

2条回答
beautiful°
2楼-- · 2020-04-19 15:19

Have you debugged and checked that your navigationController isn't nil ?

查看更多
何必那么认真
3楼-- · 2020-04-19 15:22

You must check first from which button click action you are push viewcontroller That viewcontroller must be embed in UINavigationcontroller, after that you will able to push viewcontroller from that Navigation viewcontroller.

Your parent Viewcontroller must be embed in UINavigationviewcontroller.

查看更多
登录 后发表回答