iOS/ cocoa : UIAlertView throwing EXC_BAD_ACCESS

标签 ios cocoa

似乎是一个令人震惊的微不足道的差异。将 otherButtonTitles 的非 nil 值传递给 UIAlerView 会爆炸。

工作:

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:@"Login with your credentials"
                      message:nil
                      delegate:nil
                      cancelButtonTitle:@"Cancel"
                      otherButtonTitles:nil];

不工作:

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:@"Login with your credentials"
                      message:nil
                      delegate:nil
                      cancelButtonTitle:@"Cancel"
                      otherButtonTitles:@"OK"];

什么给了?

最佳答案

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:@"Login with your credentials"
                      message:nil
                      delegate:nil
                      cancelButtonTitle:@"Cancel"
                      otherButtonTitles:@"OK1",@"OK2",nil];

最后一个参数是一个多参数,应该以 nil 结尾。

关于iOS/ cocoa : UIAlertView throwing EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11910539/

相关文章:

ios - iOS中如何实现长振动

ios - 如何创建 overlaySKScene SWIFT Xcode 来显示 HUD 或控件?

cocoa - NSImage 加载 Windows 光标 .cur 中的热点?

macos - 如何在可编写脚本的应用程序中将任意 AppleScript 记录传递给 Cocoa?

iphone - 如何编辑 NSUserDefaults 中的存储值

iphone - 如果主机在 2-3 秒内没有响应,则设置超时

ios - 使用NotificationCenter在AVPlayer中替换视频文件

ios新游戏项目,矩形显示在屏幕外?

ios - QuickBlox Opponent 视频和音频流不来?

objective-c - 如何检查 Finder 是否将具有给定扩展名的目录显示为包?