1

這是情況:我有一個類MainView(這是一個UIViewController),並從它調用一個UIActionSheetDelegate類。我想使用的方法presentViewController,但下面的代碼無法正常工作(目前被稱爲在ActionSheet類):如何調用presentViewController?

[self presentViewController:myViewController animated:YES]; 

我有點困惑就在那裏我應該叫從方法(的MainView或ActionSheetDelegate )。

在此先感謝。

回答

8

你叫上方法的UIViewController中那是你的MainView,並它UIViewController中,你想成爲ActionSheet。

[mainViewController presentViewController:actionSheetController animated:YES]; 

要消除UIActionSheet,dimissWithClickedButtonIndex:animated:是可以實現的UIActionSheet的方法。該方法可以由任何人調用(因此,如果你想從你的主視圖中解僱它,請參考操作表並做類似於[self.myActionSheet dismissWithClickedButtonIndex:0 animated:YES];

只要用戶點擊「取消」按鈕,也會調用該方法

+0

好,那我該如何解除ActionSheetController的視圖 [self dismissViewControllerAnimated:YES]不起作用 – Gary 2011-06-13 14:41:24

+0

編輯:爲了可讀性增加額外的信息給答案。 – 2011-06-13 14:45:30

相關問題