如何创建“otherButtonTitles”?
我让 AlertView 与“cancelButtonTitle:@“Cancel””和“otherButtonTitles:nil”完美配合。我的问题是如何获得其他按钮。
当我只更改“otherButtonTitles:@”2nd Button””时,iPhone 模拟器就会从应用程序中崩溃并进入主屏幕。
I have the AlertView working perfectly with a "cancelButtonTitle:@"Cancel"" and "otherButtonTitles:nil". My question is how to get other buttons.
When I only change the "otherButtonTitles:@"2nd Button"", then the iPhone simulator just crashes out of the app and into the homescreen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您希望像这样结束方法调用:
...
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1Title", @"Button2Title", nil];
这与您在 String 中看到的模式相同格式化,其中参数列表可以是任意长度。通常参数列表以 nil 结尾。不要忘记零。
You want to end your method call like this:
...
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1Title", @"Button2Title", nil];
This is the same pattern you see in String formatting, where the list of arguments can be of any length. Usually the argument list is then nil-terminated. Don't forget the nil.
完全就像 Kevin 所说的,但作为补充,您还可以将目标操作分配给其他按钮。
当您实例化
UIAlertView
时,将delegate
参数设置为self
,然后将以下方法添加到您的对象:`
Exactly like Kevin said, but as an addendum to that, you can also assign target-actions to the other buttons.
When you instantiate the
UIAlertView
, set thedelegate
argument toself
, then add the following method to your object:`