开发者

Switching xib's in iPhone SDK?

I'm having issues with switching xib's when I try to from my second view into the third.

I get into the second view from the first like this...

-(IBAction)startButtonClicked:(id)sender{

    Number2ViewController *screen = [[Number2ViewController alloc] initWithNibName:nil bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:screen animated:YES];
    [screen release];

    }

But when I'm in the second view trying to get to the third view, the app crashes...

-(IBAction)nextButtonClicked:(id)sender{

    Number3ViewController *screen = [[Number3ViewController alloc] initWithNibName:nil bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:screen animated:YES];
    [screen release];

    }

I know how to go into one view and then immediately back开发者_如何学运维 using

[self dismissModalViewControllerAnimated:YES];

How do you just keep going to different views though without having to go back first?


Based on what you've written, you're probably a lot better off using a UINavigationController for this. It's specifically designed to be able to push new controllers in and manage notifications when these controllers change (like a new one is added or the current one is removed). presentModalViewController: is really designed for when you want to present a new view that takes over the entire application, performs a single function and goes away. Examples of this would be sending an email from within your app, viewing an external web page, taking a photo, presenting some about text, changing settings or other things like this. It's not really designed to manage a stack of view controllers that actually interact with each other.


You should take a look at UINavigationController

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜