UIActionSheet 类有一个visible 属性。如果操作表正在显示,则返回YES,否则返回NO。这应该能让你知道它是否被解雇了。
您还可以使用actionSheetCancel: 和/或actionSheet:didDismissWithButtonIndex: 实现一些UIActionSheetDelegate 方法来了解它何时被解除或取消。
编辑:
为确保接收 UIActionSheet 的委托调用,请务必在控制器的接口声明 (.h) 中指明:
@interface YourViewController : UIViewController<UIActionSheetDelegate>
@end
然后在控制器的实现中(.m):
- (void)actionSheetCancel:(UIActionSheet *)actionSheet {
NSLog(@"action sheet is about to be cancelled");
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"action sheet was dismissed");
}
编辑 2:
我刚刚查看了SHKActionSheet 类的代码,结果发现它没有实现actionSheetCancel: 方法,这就是您没有收到它的原因。但是,它确实实现了actionSheet:didDismissWithButtonIndex: 方法:
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{
// Sharers
if (buttonIndex >= 0 && buttonIndex < sharers.count)
{
[NSClassFromString([sharers objectAtIndex:buttonIndex]) performSelector:@selector(shareItem:) withObject:item];
}
// More
else if (buttonIndex == sharers.count)
{
SHKShareMenu *shareMenu = [[SHKCustomShareMenu alloc] initWithStyle:UITableViewStyleGrouped];
shareMenu.item = item;
[[SHK currentHelper] showViewController:shareMenu];
[shareMenu release];
}
[super dismissWithClickedButtonIndex:buttonIndex animated:animated];
}
如果您想收到actionSheetCancel: 方法的通知,只需将其添加到 SHKActionSheet.m 文件中即可:
- (void)actionSheetCancel:(UIActionSheet *)actionSheet {
[super actionSheetCancel:actionSheet];
}
然后您的控制器中的委托方法将被正确调用:)
UIActionSheet Class Reference
UIActionSheetDelegate Protocol Reference