2015-12-16 21 views
0

Cancel Button 代碼取消按鈕是導航視圖中取消按鈕不工作

- (IBAction)cancelButton:(id)sender { 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

,追查程序,我可以看到該方法被調用但是視圖不會dissmissing上一個視圖控制器。

回答

2

如果使用導航視圖控制器,你應該使用

[self.navigationController popViewControllerAnimated:YES]; 

代替dismissViewControllerAnimated

PS其實,我覺得你用故事板和塞格斯在這種情況下,你應該使用UnwindSegue What are Unwind segues for and how do you use them? 另外,應閱讀有關應用程序導航的一些常見文檔...

+0

找不到popViewControllerAnimated。當我使用完整的語法時,我得到'沒有可見的@interface'AddConatctViewController'聲明選擇器'popViewControllerAnimated:'' – Rishab

+0

抱歉,我錯過了navigationController。檢查固定代碼 – Igor

+0

phew ...是的作品 – Rishab