开发者

How to call presentViewController?

Here is the situation: I have a class MainView (which is a UIViewController) and call from it an UIActionSheetDelegate class. I want to use the method presentViewController, but the following code does not work (currently being called in the ActionSheet class):

[self presentViewController:myViewController animated:YES];

I am a little confused regarding where I should call the method from (MainView or the ActionSheetDeleg开发者_StackOverflowate).

Thanks in advance.


You call the method on the UIViewController that is your MainView, and pass it your UIViewController you want to be the ActionSheet.

[mainViewController presentViewController:actionSheetController animated:YES];

To dismiss the UIActionSheet, dimissWithClickedButtonIndex:animated: is a method for the UIActionSheet that you can implement. The method can be called by whoever (so if you want to dismiss it from your mainview have a reference to the action sheet and do something like [self.myActionSheet dismissWithClickedButtonIndex:0 animated:YES];

The method is also called whenever the 'cancel' button is clicked by the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜