2010-04-07 27 views
0

我在嘗試從第二個視圖切換到第三個視圖時遇到切換xib的問題。在iPhone SDK中切換xib?

我進入從第一個這樣的第二種觀點...

-(IBAction)startButtonClicked:(id)sender{ 

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

    } 

但是,當我在試圖讓第三視圖的第二視圖,應用程序崩潰...

-(IBAction)nextButtonClicked:(id)sender{ 

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

    } 

我知道如何去到一個視圖,然後立即回用

[self dismissModalViewControllerAnimated:YES]; 

你怎麼只保留打算d儘管有不同意見,但不必先回去?

+0

如果你可以發佈關於崩潰,這可能有助於細節。查看http://stackoverflow.com/questions/2588853/the-community-driven-gdb-primer – fbrereto 2010-04-07 17:50:50

+0

一旦nextButtonClicked被激活,應用程序崩潰 – NextRev 2010-04-07 17:54:18

回答

4

根據你寫的內容,你使用UINavigationController可能會好很多。它專門設計用於在這些控制器發生變化時(如添加新控制器或刪除當前控制器),能夠推送新控制器並管理通知。 presentModalViewController:是專爲您想要呈現接管整個應用程序,執行單一功能並消失的新視圖而設計的。這樣做的例子是從您的應用程序發送電子郵件,查看外部網頁,拍照,呈現一些關於文本,更改設置或其他類似的內容。它並不是真正用於管理實際上可以相互交互的視圖控制器堆棧。

0

你應該看看UINavigationController