在 UIActionSheet 上显示 UIAlertView
我已将 UIActionSheet 子类化以显示 UIPickerView。这个想法是用户将从选择器中选择一个值,单击“完成”(操作表工具栏中的按钮)。这将弹出一个提示,要求用户确认选择(因为这可能是一种破坏性操作)。
问题是,UIActionSheet 优先于警报。 UIAlertView 显示在后台,用户无法选择任何选项。有什么方法可以将警报视图放置在操作表上方吗?
I've subclassed UIActionSheet to display a UIPickerView. The idea is the user will select a value from the picker, click Done (a button in a toolbar in the actionsheet). This will pop up a prompt asking the user to confirm the choice (as it is potentially a destructive action).
The issue is, the UIActionSheet takes precedence over the alert. The UIAlertView is displayed in the background and there's no way for the user to select any options. Is there any way to position the alert view above the action sheet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
很可能有一种方法可以实现这一点,但我的猜测是它不是非常优雅/直接。我建议不要让两个模态视图争夺优先级,而是创建一个新的自定义
UIView
来充当输入视图(而不是直接覆盖UIActionSheet
)并呈现从那里的UIAlertView
。使您的新输入视图看起来像UIActionSheet
需要一些额外的工作,但这里有两篇很棒的文章可能会有所帮助:如何使视图看起来像
UIActionSheet
: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 very well may be a way to accomplish this, but my guess would be it's not terribly elegant/straightforward. Instead of having two modal views fight for precedence, I'd suggest instead making a new custom
UIView
to serve as your input view (as opposed to overwritingUIActionSheet
directly) and presenting theUIAlertView
from there. It will take a little extra work to make your new input view look like aUIActionSheet
, but here are two great articles which may help:How to make view appear like a
UIActionSheet
:http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html
Some nice looking gradient buttons you could use to match
UIActionSheet
's:http://iphonedevelopment.blogspot.com/2010/05/gradient-buttons-yet-again.html
我无法真正开始工作,所以我没有浪费时间去破解一个丑陋的解决方案,而是在显示警报时忽略了操作表。如果用户单击“确定”,我将继续执行该操作,如果用户单击“取消”,我将再次显示操作表。运行良好。
I couldn't really get working so rather than wasting time hacking up an ugly solution, I ended up dismissing the action sheet when the alert was shown. If the user clicked OK, I continued with the action, if the user clicked Cancel, I presented the action sheet again. It's working fine.