I have created View based application, here i need to navigate between views when button pressed.
so in first view controller i have created action for button pressed.
-(IBAction)loadSecondView:(id)sender
{
SecondView *sView = [[SecondView alloc]initWithNibName:@"SecondView" bundle:nil];
[self.navigationController pushViewController:sView animated:YES];
[sView release];
}
this code is not working, anything i am missing,
i can do this by [self.view addSubview:sView]; but i need navigation effect.
Thanks in advance.
You can’t just hook a
UIViewinstance to a navigation controller, that’s not how they work.Take a look at the “Navigation-based Application” template in Xcode, to learn how navigation controllers work.
You can use view controllers while hiding the navigation bar:
You can then map
UIButtoninstances to selectors that push or pop view controllers, while keeping the navigation bar hidden.These button instances are subviews of the view controller’s
viewproperty.Hiding the navigation bar can help provide the illusion that you are not using a navigation controller, while giving you all the functionality of the navigation controller.