我是 AlertViews 的新手。已经按照我在此处找到的示例进行了设置,包括在我的 .h 中设置委托方法,但是当我调试时发现它没有达到我的 clickedButtonAtIndex 方法。可能缺少一些简单的东西:-/ 任何解决此问题的帮助将不胜感激,谢谢。这是我的代码:
.h 文件
@interface LineDetailViewController : UIViewController <UIAlertViewDelegate>
. .m 文件:
- (IBAction)removeLineButton:(UIButton *)sender {
NSString * requestSubmitText = [NSString stringWithFormat:@"Hey Bro are you sure you want to remove this line you created, it will also remove all the reviews attached and can not be undone?"];
UIAlertView *removeLineRequest = [[UIAlertView alloc] initWithTitle:@"WARNING!!"
message:requestSubmitText
delegate:nil
cancelButtonTitle:@"Remove It"
otherButtonTitles:@"Cancel",nil];
[removeLineRequest show];
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{
//if (buttonIndex == [alertView cancelButtonIndex]){
if (buttonIndex == 0){
NSLog(@"Cancel button pressed");
}else{
NSLog(@"other button pressed");
}
}