0

テーブル ビュー コントローラーでユーザー オプションを提供する UIActionSheet があります。以前は問題なく実装していましたが、何らかの理由で、ボタンがクリックされたときにイベント ハンドラーが起動しません。私のヘッダー ファイルでは、次のように適切なデリゲートを実装しました。

@interface GaugeDetailTableViewController : UITableViewController <UIActionSheetDelegate>

私の実装では、アクション シートをサポートする次のコードがあります。

-(void)loadPopup{
UIActionSheet *popup = [[UIActionSheet alloc]
                        initWithTitle:@"Options"
                        delegate:nil
                        cancelButtonTitle:@"Cancel"
                        destructiveButtonTitle:nil
                        otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil];
popup.actionSheetStyle = UIActionSheetStyleDefault;

[popup showInView:self.view];
}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"%d\n", buttonIndex);
}

アクション シートはビュー コントローラーに正しく表示されますが、何らかの理由で、アクション シートのクリック イベント ハンドラーに到達しません。助言がありますか?ありがとう!

4

2 に答える 2

4

デリゲートを設定する必要があります。

UIActionSheet *popup = [[UIActionSheet alloc]
                        initWithTitle:@"Options"
                        delegate:self
                        cancelButtonTitle:@"Cancel"
                        destructiveButtonTitle:nil
                        otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil];
popup.actionSheetStyle = UIActionSheetStyleDefault;
于 2013-11-13T16:28:39.507 に答える
3

デリゲートの設定を忘れているようです。実装してUIActionSheetDelegate(持っているように見えます)、デリゲートを設定する必要があります!

于 2013-11-13T16:28:20.697 に答える