如何向现有的 UIActionSheet 添加按钮?
我有这段代码:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
initWithTitle:@"Illustrations"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: @"ABC", @"XYZ",
nil] autorelease];
UIImage *image = // whatever, snip
if (image != nil)
{
[actionSheet addButtonWithTitle:@"LMNOP"];
}
它在有条件地添加我的 LMNOP 按钮方面做得很好。
...取消按钮之后。
如何使用条件按钮构建操作表?可悲的是,我不能这样做:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
// ... etc.
otherButtonTitles: someMutableArray
// ... etc.
因为那肯定会有帮助。
有什么想法吗?
谢谢!
I have this code:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
initWithTitle:@"Illustrations"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: @"ABC", @"XYZ",
nil] autorelease];
UIImage *image = // whatever, snip
if (image != nil)
{
[actionSheet addButtonWithTitle:@"LMNOP"];
}
and it does a great job of adding my LMNOP button conditionally.
...AFTER the cancel button.
How can I construct my action sheet with a conditional button? Sadly, I can't do:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
// ... etc.
otherButtonTitles: someMutableArray
// ... etc.
because that would certainly help.
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 init 方法之后添加所有按钮。
You can add all buttons after the init method.
我正在为 iOS 4 进行编码,这就是使用的方法。您只需在 otherbutton 部分中添加所需的按钮标题即可。
im coding in for iOS 4 and this is the method that is used. You just add the title you want for the button in the otherbutton sections.