如何调用presentViewController?

发布于 2024-11-15 05:21:34 字数 296 浏览 2 评论 0原文

情况是这样的:我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清欢 2024-11-22 05:21:34

您在作为 MainView 的 UIViewController 上调用该方法,并将其传递给您想要作为 ActionSheet 的 UIViewController。

[mainViewController presentViewController:actionSheetController animated:YES];

要关闭 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.

[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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文