Possible Duplicate:
Why can't I push a new view controller onto the current view?
Why is my new view controller not appearing?
I need to push my view controller from my navigationController, but after having done an NSLog statement to find out why nothing was showing with the following code, I realised that it was returning null:
-(IBAction)doChangePasscode{
NSLog(@"Change Passcode Screen Loaded!");
ChangePasscode *cpscreen = [[ChangePasscode alloc] initWithNibName:@"ChangePasscode" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:cpscreen animated:YES];
NSLog(@"%@",self.navigationController);
}
Why is this happening? What can I do to return a proper value other than (null)?
Like everyone has explained in this and Why is my new view controller not appearing?, you need to have a navigation controller first. Use that nav controller to push your view controllers and then your view controllers will no longer have null for the
navigationControllerproperty.In this example
someSecondViewControllerwould be theselfin your code above:Please review these:
View Controller Programming Guide for iOS
UINavigationController Docs
UIViewController Docs