您好我写了下面的代码:检查其UIAlertVeiw被点击
- (IBAction)DelBlockB:(id)sender {
confirmDelB = [[UIAlertView alloc] initWithTitle:@"Attention" message:[NSString stringWithFormat:@"are you sure you want to delete and block %@", idnameArr[2]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];
[confirmDelB show];
}
- (IBAction)DelFB:(id)sender {
confirmDel = [[UIAlertView alloc] initWithTitle:@"Attention" message:[NSString stringWithFormat:@"are you sure you want to delete %@", idnameArr[2]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel",nil];
[confirmDel show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"ok");
}
else {
NSLog(@"cancel");
}
}
,其中方法“clickedButtonAtIndex”将返回一个答案无论是什么UIAlertView中被压, 我怎么能显示答案只有一个警报被点击了?
使用新的[UIAlertController](https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIAlertController_class/index。HTML#// apple_ref/OCC/instm/UIAlertController /的addAction :)。它可以让你添加行动,而不是布线代表。 – CrimsonChris 2014-09-29 16:19:12
@CrimsonChris好的,太棒了。我不知道,谢谢。不过,如果你想支持iOS7,我的答案仍然有效:D – Fogmeister 2014-09-29 16:28:19
如果你的子类UIAlertView是iOS7,你仍然可以支持块。 – CrimsonChris 2014-09-29 16:29:01