如何调用presentViewController?
情况是这样的:我有一个 MainView 类(它是一个 UIViewController)并从中调用 UIActionSheetDelegate 类。我想使用方法presentViewController,但以下代码不起作用(当前在ActionSheet类中调用):
[self presentViewController:myViewController animated:YES];
我对应该从哪里调用该方法(MainView或ActionSheetDelegate)有点困惑。
提前致谢。
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 ActionSheetDelegate).
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在作为 MainView 的 UIViewController 上调用该方法,并将其传递给您想要作为 ActionSheet 的 UIViewController。
要关闭 UIActionSheet,
dimissWithClickedButtonIndex:animated:
是您可以实现的 UIActionSheet 的一种方法。该方法可以由任何人调用(因此,如果您想从主视图中消除它,请引用操作表并执行类似[self.myActionSheet dismissWithClickedButtonIndex:0animated:YES];
的方法每当用户单击“取消”按钮时也会调用。
You call the method on the UIViewController that is your MainView, and pass it your UIViewController you want to be the ActionSheet.
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.