2个带有3个按钮的UIAlertView?

Raf*_*ael 0 iphone xcode ipod-touch uialertview

我想知道如何制作2个UIAlertView,有3个按钮,UIAlertViews(2)需要不同,选项和动作......如何???

And*_*rew 8

试试这个:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Message." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"Button 2", @"Button 3", nil];
alert.tag = 1;               
[alert show];
Run Code Online (Sandbox Code Playgroud)

然后对下一个alertView执行相同操作,只需将标记更改为2即可

然后运行此方法

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
     if(alert.tag == 1) {
          //the alert tag 1 was just closed - do something
     }
}
Run Code Online (Sandbox Code Playgroud)

另外 - 确保你包括 UIAlertViewDelegate