【问题标题】:How to call presentViewController?如何调用presentViewController?
【发布时间】:2011-06-13 14:28:06
【问题描述】:

情况如下:我有一个 MainView 类(它是一个 UIViewController)并从中调用一个 UIActionSheetDelegate 类。我想使用presentViewController方法,但是下面的代码不起作用(目前在ActionSheet类中调用):

[self presentViewController:myViewController animated:YES];

对于我应该从哪里调用方法(MainView 或 ActionSheetDelegate)我有点困惑。

提前致谢。

【问题讨论】:

    标签: ios uiviewcontroller uiactionsheet presentmodalviewcontroller


    【解决方案1】:

    你调用方法on UIViewController 是你的MainView,并传递你的UIViewController 你想成为ActionSheet。

    [mainViewController presentViewController:actionSheetController animated:YES];
    

    要关闭 UIActionSheet,dimissWithClickedButtonIndex:animated: 是您可以实现的 UIActionSheet 方法。该方法可以由任何人调用(因此,如果您想从主视图中将其关闭,请参考操作表并执行类似[self.myActionSheet dismissWithClickedButtonIndex:0 animated:YES];

    每当用户单击“取消”按钮时,也会调用该方法。

    【讨论】:

    • 太棒了。那么我如何从视图中关闭 ActionSheetController 。 [self dismissViewControllerAnimated:YES] 不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 1970-01-01
    相关资源
    最近更新 更多