开发者

Showing an UIAlertView over a UIActionSheet

I've sub开发者_开发百科classed 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜