1

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

[self presentViewController:myViewController animated:YES];

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

提前致谢。

4

1 回答 1

8

您在作为 MainView 的 UIViewController调用该方法,并将您希望成为 ActionSheet 的 UIViewController传递给它。

[mainViewController presentViewController:actionSheetController animated:YES];

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

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

于 2011-06-13T14:31:54.113 回答