【发布时间】:2010-08-16 08:49:57
【问题描述】:
我正在尝试在按下按钮时进行呼叫和提醒。我用这个:
-(IBAction)Add {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"add button pressed"
message:@"Add to record"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil ];
[alert show];
[alert release];
}
好的,这里没问题,出现两个按钮,确定和取消。现在我想检测我使用的是哪个按钮:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
//just to show its working, i call another alert view
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"OK WORKIng well"
message:@"no error" delegate:nil
cancelButtonTitle:@"IWORKS"
otherButtonTitles:@"NO PRB", nil];
[alert show];
[alert release];
}
else
{
NSLog(@"cancel");
}
}
现在问题来了。我无法检测到按下了哪个按钮;第二个警报视图不显示。我已经检查了几次代码,似乎没有任何问题。也没有错误/警告。
【问题讨论】:
-
在另一个警报之后直接显示一个警报可能不是一个好主意——只是一个提示。
标签: iphone xcode uialertview