UIAlertView带有iPhone中的两个按钮

Kay*_*Kay 3 iphone cocoa-touch uialertview ios

我正在尝试按下按钮时显示警报视图,因此我编写了如下代码:

- (IBAction)signUpComplete: (id)sender {
  UIAlertView* alert_view = [[UIAlertView alloc]
      initWithTitle: @"test" message: @"test" delegate: nil cancelButtonTitle: @"cancel" otherButtonTitles: @"OK"];
  [alert_view show];
  [alert_view release];
}
Run Code Online (Sandbox Code Playgroud)

但是这个代码在initWithTitle方法中遇到以下异常崩溃:

2010-08-11 03:03:18.697 Polaris [1155:207]*** - [UIButton copyWithZone:]:无法识别的选择器发送到实例0x176af0
2010-08-11 03:03:18.700 Polaris [1155:207]***由于未捕获的异常而终止应用程序

0x176af0与参数'sender'的值相同,后者是其动作处理程序为signUpComplete的按钮:我认为问题是otherButtonTitles:参数,因为它与参数nil一起工作正常.因此创建"确定"按钮时出现问题.我的代码有什么问题吗?

谢谢!

Vla*_*mir 5

otherButtonTitles列表必须以nil结尾:

UIAlertView* alert_view = [[UIAlertView alloc]
      initWithTitle: @"test" message: @"test" delegate: nil 
      cancelButtonTitle: @"cancel" otherButtonTitles: @"OK", nil];
Run Code Online (Sandbox Code Playgroud)