我有这个 2 按钮警报视图:
UIAlertView* message = [[UIAlertView alloc]
initWithTitle: @"Delete?" message: @"This business will be deleted permenently." delegate: nil
cancelButtonTitle: @"Cancel" otherButtonTitles: @"Delete", nil];
[message show];
我也有这个方法:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Delete"])
{
NSLog(@"Button DELETE was selected.");
}
else if([title isEqualToString:@"Cancel"])
{
NSLog(@"Button CANCEL was selected.");
}
}
我将其添加到 .h 文件中:
<UIAlertViewDelegate>
现在,当按下任一按钮时,它只会关闭对话框。可以取消,但我怎么知道何时按下删除按钮?
谢谢!