2009-11-29 74 views
2

我已經閱讀了所有其他用戶對問題的描述,但他們似乎沒有得出適用於我的結果,或者他們以'我修復了它們 - 感謝您的幫助'而結束了,但之後他們忽略了分享其解決方案。這裏是我的代碼來呈現和解僱(所有的關鍵對象是我的應用程序委託的屬性,我試圖調出一個關於頁面,然後返回到應用程序,我做了什麼錯誤??dismissModalViewControllerAnimated:不會關閉頁面嗎?

當前模態VC作品):

-(IBAction) showInfoButton: (id) sender { 
NSLog(@"%s", __FUNCTION__); 

if(aboutViewController == nil) { 
    aboutViewController = [[[AboutViewController alloc] initWithNibName:@"About" bundle:[NSBundle mainBundle]] autorelease]; 
    [appDelegate.window addSubview: aboutViewController.view]; 
} 

appDelegate.modalNavigationController = [[UINavigationController alloc] initWithRootViewController:aboutViewController]; 

[appDelegate.modalNavigationController presentModalViewController:appDelegate.modalNavigationController animated: YES]; 

}

我從關於視圖控制器辭退(不工作):

-(IBAction) dismissAbout: (id) sender { 
NSLog(@"%s", __FUNCTION__); 

[self dismissModalViewControllerAnimated:YES]; 

}

我已經嘗試過動畫'NO',但是沒有任何區別。我試圖將我的代碼與其他代碼進行匹配,但這沒有任何區別。我正在轉圈,所以任何幫助表示讚賞。

回答

4

XCode中flipside控制器的默認模板,建議您需要在模態控制器中有一個委託,將您指回您的初始控制器。最簡單的是,如果您在xcode中創建一個新項目,請選擇Utility應用程序並查看代碼。

總之,這應該是你的主屏幕上的代碼控制器

- (IBAction)showInfo; 
{  

    InfoScreen * aboutViewController = [[InfoScreen alloc] initWithNibName:@"InfoScreen" bundle:nil]; 
    aboutViewController.delegate =self; 

    [self presentModalViewController: aboutViewController animated:YES]; 

    [aboutViewController release]; 
} 

- (void)flipsideViewControllerDidFinish; 
{ 

    [self dismissModalViewControllerAnimated:YES]; 
} 

而在你有關屏幕後退按鈕這樣的操作:

- (IBAction)done { 
    [self.delegate flipsideViewControllerDidFinish]; 
    self.delegate = nil; 
} 

有一個爲了讓委託響應flipsideViewControllerDidFinish等代碼更多的代碼,這不需要你關心的控制器的解僱問題,但在Utility應用程序模板中查找會清楚。

+0

謝謝艾康。您的回覆看起來像是正確的答案,但我必須將我的代碼全部頂起來,以至於無法像您所說的那樣簡單地使其工作。我會重構我的代碼(即從頭開始:)),當我得到它的工作時,我會標記你的答案。 – mobibob 2009-12-09 03:52:48

+1

我已經差不多了......我有導航到/從,但它不是模態。今晚,我應該完成這個併發布我的新知識。 – mobibob 2009-12-09 14:34:34

+1

好的。我按照Ican的建議閱讀了文檔(再次),並且引發我關注的是關於「loadView」方法的聲明。只要我把這些知識放在頭腦中,並且知道我已經完成了關於我的關於頁面視圖的「addSubview」,我意識到我需要一個「removeSubview」類。我發現在附加代碼 - (IBAction)解僱關於:(id)發件人{ \t NSLog(@「%s」,__FUNCTION__); \t \t [self.view removeFromSuperview]; \t [self dismissModalViewControllerAnimated:YES]; } Ican,你會得到答案複選標記。謝謝! – mobibob 2009-12-11 04:35:06