I don’t know if my question will be clear or not, but i’m starting basic stuff with iphone programming, and i’m trying to understand how to go from a screen to another.
lets say i have a screen with a “next page” button and another page with a “return” button.
I have a general idea of how to do this, but I don’t know how to put it together.
I think I need an IBAction method for each button, and in each method a navigation controller with pushViewController. So far, i’ve tried the following code, but even if it compiles properly and runs when i push the button, there is no change of screen…
-(IBAction) toNext(id)sender{
NSLog(@"before code");
NextViewController *nvc = [[NextViewController alloc] initWithNibName:@"NextView" bundle:nil];
[self.navigationController pushViewController:nvc animated:YES];
[nvc release];
NSLog(@"after code");
}
If someone had a nice tuto for me, it could be of some help…
thx
Your code won’t work if your view controller (and it’s not clear that you are even doing this from a view controller) doesn’t have a navigationcontroller.
Secondly, you should pop to return, not push a second time.
There are different ways of moving between views. The simplest is to call addSubview: with a view, which can be seen in the app delegate code of any app created from a template.
The two others are the push/pop used with navigation controllers (typically from a view controller), and present modal, which has to be called with a view controller as well. The differences with these latter two are the animations used, and the assumption of how the views will be navigated away from.