我有一个警告视图,当我点击“是”按钮时,它应该产生另一个警告视图和一个提示消息,但是这并没有发生。我无法找出问题所在。这是我的代码:
-(void)myMethod {
UIAlertView *saveAlert = [[UIAlertView alloc] initWithTitle:@"First Message"
message:@"My First message"
delegate:nil
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes", nil];
saveAlert.tag=0;
[saveAlert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
}
这是我使用的方法来提供不同警告视图的功能。
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag==0) {
if (buttonIndex == 0)
{
//Code for Cancel button
}
if (buttonIndex == 1)
{
//code for yes button
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"Successfully displayed First Message";
hud.margin = 10.f;
hud.yOffset = 150.f;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:3];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Second Message"
message:@"My second message"
delegate:nil
cancelButtonTitle:@"No"
otherButtonTitles:@"Yes",nil];
alert.tag=1;
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
}
}
if (alertView.tag==1) {
if (buttonIndex == 0)
{
//Code for Cancel button
}
if (buttonIndex == 1)
{
//Code for yes Button
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"Succesfully displayed Second Message";
hud.margin = 10.f;
hud.yOffset = 150.f;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:3];
}
}
}
有人能帮忙找到问题吗?为什么我在第一个警告框中点击“是”按钮后无法获得第二个警告框?