我有一些常规的警报视图和一个名为' UINotificationAlertView‘的自定义警报视图,我希望自定义UINotificationAlertView上的'ok’按钮单击事件使用第二种方法,而不是第一种方法。我该怎么做呢?我是objective c的新手,如果这是一个愚蠢的问题,我很抱歉。
UINotificationAlertView *message = [[UINotificationAlertView alloc]
initWithTitle:@""
message:row.alertBody
delegate:self.
cancelButtonTitle:@"OK"
otherButtonTitles:nil];App delgate中的两种方法:
//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];
}
}发布于 2012-06-14 21:52:16
试一试
在.h文件中,输入:
@interface YourClassName : UIViewController<UIAlertViewDelegate>在.m文件中:
message.delegate = self;
https://stackoverflow.com/questions/11034369
复制相似问题