0

いくつかの通常のアラート ビューと「UINotificationAlertView」というカスタム アラート ビューがあります。カスタム UINotificationAlertView の「OK」ボタン クリック イベントで、最初のメソッドではなく 2 番目のメソッドを使用する必要があります。これどうやってするの?Objective C は初めてなので、これがばかげた質問である場合は申し訳ありません。

UINotificationAlertView *message = [[UINotificationAlertView alloc]
                                    initWithTitle:@""
                                    message:row.alertBody
                                    delegate:self.
                                    cancelButtonTitle:@"OK"                      
                                    otherButtonTitles:nil];

アプリ デリゲートの両方のメソッド:

//UIAlertView delegate
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

        if(buttonIndex == kNo) {
        } else {
            //Close by suspending...
            [[UIApplication sharedApplication] suspend];
        }
    }
    - (void)alertNotificationView:(UINotificationAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
        NSLog(@"phils new delegate");
        if(buttonIndex == kNo) {
        } else {
            //Close by suspending...
            [[UIApplication sharedApplication] suspend];
        }
    }
4

1 に答える 1

1

試す

.h ファイルに次のように入力します。

@interface YourClassName : UIViewController<UIAlertViewDelegate>

.m ファイルで:

message.delegate = self;

于 2012-06-14T13:52:16.437 に答える