2013-03-18 64 views
-2

我在這方面遇到了很多麻煩,我似乎無法找到專門針對這種情況的答案。我有一個UITableViewController呈現一個UIActionSheet,我如何使一個操作表選項顯示一個模態視圖?

我有一個UITableViewController有一個按鈕,被點擊時呈現一個UIActionSheet有幾個選項。我想要其中一個選項來調出另一個視圖控制器,該視圖控制器已經出現在我的故事板中,可以顯示。

UIActionSheet已完全實現,同時還有actionSheet:clickedButtonAtIndex:,我只是不知道該怎麼做。

我試圖在它裏面有這樣的:

NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex]; 

if ([buttonTitle isEqualToString:@"Text"]) { 
    AddTextViewController *addTextViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"addTextViewController"]; 
    [self presentViewController:addTextViewController animated:YES]; 
} 

,但我得到一個錯誤說:No visible @interface for 'RootViewController' declares the selector 'presentViewController:animated:所以這不是工作要麼。

我應該在這裏做什麼?

+0

你想問這個問題多少次? – Levi 2013-03-18 16:04:55

回答

2

沒有這樣的方法,如presentViewController:animated:。該方法實際上是presentViewController:animated:completion:

因此改變:

[self presentViewController:addTextViewController animated:YES]; 

到:

[self presentViewController:addTextViewController animated:YES completion:nil]; 

傳遞一個實際完成塊如果需要的話。

+1

有趣,這正是我所說的:http://stackoverflow.com/questions/15478786/how-do-i-present-a-modal-view-upon-an-option-in-uiactionsheet-being-tapped#comment21908800_15478839 – 2013-03-18 15:58:47

+0

我得到這個錯誤的第一個解決方案:***由於未捕獲的異常'NSInternalInconsistencyException',原因:' - [UITableViewController loadView]加載了「2Pv-MD-gdY-view-bDF-TR-G6E」筆尖而終止應用程序,但沒有得到一個UITableView。「 – 2013-03-18 16:24:10

相關問題