多个红色/破坏性按钮 UIActionSheet
有没有办法在 iPhone 应用程序的 UIActionSheet 中拥有超过 1 个红色“破坏性按钮”?
我需要在同一个操作表中有不同的清晰选项,一个删除所有内容,一个删除较少内容,所以两者都需要是红色的。
Is there any way to have more than 1 red "destructive button" in an iPhone app's UIActionSheet?
I need to have different clear options, in the same action sheet, one where it deletes everything and one where it deletes less, so both need to be red.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚为 iPhone 创建了一个简单的可定制的 UIActionSheet 替代品,以便在类似的情况下使用。它不使用标准外观,但这可以更改。也许它对你有用。
https://github.com/4marcus/WMActionSheet
I just created a simple customizable replacement for UIActionSheet for iPhone to use in a similar case. It does not use the standard appearance, but this can be changed. Probably it is of any use to you.
https://github.com/4marcus/WMActionSheet
这个问题的发布者似乎可以管理你想要的东西......如果我理解正确的话。
在警报中使用子视图未记录
编辑:
我发誓我第一次搜索了 UIActionSheet。真的。
http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html
The poster of this question seemed to manage what you want...if i understand you correctly.
Is using subviews in Alert undocumented
EDIT:
I swear I searched for UIActionSheet the first time. Really.
http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html
标准 UIActionSheet 上不支持执行此操作的方法。您可以使用渐变按钮构建自己的“操作表”替代品,如下所示:
http://iphonedevelopment.blogspot.com/2010/05/gradient-buttons-yet-again.html
我希望有人创建一个更可定制的相似操作表替代品,但我不这样做我立刻就知道其中一个。
There's no supported way of doing this on the standard UIActionSheet. You could build your own "action sheet" replacement using gradient buttons like the ones here:
http://iphonedevelopment.blogspot.com/2010/05/gradient-buttons-yet-again.html
I would expect someone to have created a more customizable lookalike action sheet replacement, but I don't know of one off the top of my head.
在看到 griotspeak 更新的答案之前我尝试过这个:(
我使用 NSSelectorFromString 而不是 @selector() 因为这意味着它并没有真正使用未记录的东西,如果你明白我的意思的话)
它没有完全记录,但我没有我想我使用了未记录的方法。
基本上它的作用是从破坏性背景中取出红色背景并将其应用到另一个名为“取消”的按钮。
因此,如果苹果改变破坏性按钮的颜色,非破坏性按钮的颜色也会改变,而无需更新。尽管它没有使用特别对苹果安全的方法。
我在上面的注释行上遇到了一些麻烦,如果您可以帮忙,请在这里回答:performSelector:withObject:,但不使用对象
I tried this before I saw griotspeak updated answer:
(I use NSSelectorFromString rather than a @selector() because it means it's not really using undocumented things, kind of, if you get what I mean)
It's not entirely documented but I don't think I've used undocumented methods.
Basically what it does is take the red background from the destructive background and apply it to the other button named "Cancel".
So that should Apple change the color of the destructive button, so will the non-destructive-destructive change as well without needing an update. Although it doesn't use particularly Apple-safe methods.
I'm having a little bit of trouble with the commented-out line above, if you can help please answer here: performSelector:withObject:, but not with an object