开发者

navigation between screens Iphone programming

开发者 https://www.devze.com 2022-12-27 21:58 出处:网络
I don\'t know if my question will be clear or not, but i\'m starting basic stuff开发者_如何学Go with iphone programming, and i\'m trying to understand how to go from a screen to another.

I don't know if my question will be clear or not, but i'm starting basic stuff开发者_如何学Go 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.


I guess you are trying to implement a navigation based application in iPhone [Navigation Application][1]

[1]: http://theappleblog.com/2009/04/15/iphone-dev-sessions-create-a-navigation-based-application/ just go though it may be this is what you are looking for

0

精彩评论

暂无评论...
验证码 换一张
取 消