简体   繁体   English

在UIActionSheet上显示UIAlertView

[英]Showing an UIAlertView over a UIActionSheet

I've subclassed UIActionSheet to display a UIPickerView. 我将UIActionSheet子类化以显示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. 问题是,UIActionSheet优先于警报。 The UIAlertView is displayed in the background and there's no way for the user to select any options. UIAlertView显示在背景中,用户无法选择任何选项。 Is there any way to position the alert view above the action sheet? 有什么方法可以将警报视图放置在操作表上方?

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 overwriting UIActionSheet directly) and presenting the UIAlertView from there. 我建议不要使用两个模式视图来争夺优先级,而建议创建一个新的自定义UIView作为您的输入视图(与直接覆盖UIActionSheet相对)并从那里显示UIAlertView It will take a little extra work to make your new input view look like a UIActionSheet , but here are two great articles which may help: 要使您的新输入视图看起来像UIActionSheet ,将需要做一些额外的工作,但是以下两篇很棒的文章可能会有所帮助:

How to make view appear like a UIActionSheet : http://www.nearinfinity.com/blogs/andrew_homeyer/display_a_custom_uiview_like_a.html 如何使视图看起来像UIActionSheethttp : //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 您可以使用一些外观漂亮的渐变按钮来匹配UIActionSheethttp : //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. 一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM