UIActionSheet
クラスは、visible
プロパティを持っています。アクションシートが表示されている場合はYES
、そうでない場合はNO
を返します。それは、それが解雇されたかどうかを知ることができるはずです。
UIActionSheetDelegate
の方法を実装して、解読またはキャンセルされたタイミングをactionSheetCancel:
および/またはactionSheet:didDismissWithButtonIndex:
とすることもできます。
EDIT:
お使いのコントローラのインタフェース宣言(.H)に示すようにしてください、あなたのUIActionSheetのデリゲートの呼び出しを受けるようにしてくださいするには、次の
@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");
}
EDIT 2:
私はちょうどSHKActionSheet
クラスのコードを見てきましたが、それはactionSheetCancel:
メソッドを実装していないことが判明しています。その理由は受信していません。あなたはactionSheetCancel:
方法を通知することにしたい場合は、単にSHKActionSheet.mファイルにこれを追加し、
- (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];
}
:それは、しかし、actionSheet:didDismissWithButtonIndex:
メソッドを実装してい
- (void)actionSheetCancel:(UIActionSheet *)actionSheet {
[super actionSheetCancel:actionSheet];
}
あなたの中にデリゲートメソッドその後、コントローラは正常に呼び出されます:)
UIActionSheet Class Reference
UIActionSheetDelegate Protocol Reference
問題は、私がactionSheet.visibleを終了した後にテストするとアプリケーションがクラッシュすることです。 –
その場合は、私が言及したデリゲートメソッドを実装してみてください。アクションシートのデリゲートプロパティを設定していることを確認してください: 'actionSheet.delegate = self;' – Mutix
私の設定では以下を行います:\t SHKActionSheet * as [[SHKActionSheet alloc] initWithTitle:SHKLocalizedString(@ "Share") delegate:自己 cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; しかし、デリゲートの行は、自己がタイプUIActionSheetDelegateではないという警告を表示しています。私は、これが代表者の設立を止めていると思う。 –