在 UIActionSheet 上显示 UIAlertView

发布于 2024-10-06 08:31:37 字数 201 浏览 0 评论 0原文

我已将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风情万种。 2024-10-13 08:31:37

很可能有一种方法可以实现这一点,但我的猜测是它不是非常优雅/直接。我建议不要让两个模态视图争夺优先级,而是创建一个新的自定义 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 overwriting UIActionSheet directly) and presenting the UIAlertView from there. 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:

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

情归归情 2024-10-13 08:31:37

我无法真正开始工作,所以我没有浪费时间去破解一个丑陋的解决方案,而是在显示警报时忽略了操作表。如果用户单击“确定”,我将继续执行该操作,如果用户单击“取消”,我将再次显示操作表。运行良好。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文