I have a navigation controller with a rootview.
The rootview contains buttons, which push new views onto the navigation controller correctly.
However, on this rootview, I also have subview (it’s a scrolling preview like the appStore images, view made of 3 UIview items). On these UIViews, there is a button which I’d like to change the rootview navigation controller, like the other buttons.
At the moment, it builds and runs, but the new view is not pushed. Any ideas?
Click method on on the ScrollItem button:
MyViewController *newView = [[MyViewController alloc] initWithNibName:@"ManageMyPain" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:newView animated:YES];
… i guess it is because, self doesn’t have a navigation controller, but the rootview does.
Thanks!!
Yes, it is because
self.navigationControllerwill be nil if you didn’t push that controller on navigations stack or if you didn’t set it manually.So you just need to have reference to
rootViewController.navigationControllerand then[navigationController pushViewController:newView animated:YES];will work perfectly.