现在的位置: 首页 > 综合 > 正文

UIActionSheet 按钮不响应点击事件的解决方法

2013年10月10日 ⁄ 综合 ⁄ 共 685字 ⁄ 字号 评论关闭


如题,如果在项目中使用了UIActionSheet和UITabBarViewController,那么actionSheet的最底下的一个按钮可能就不会响应你的触摸事件,原因是被tabbar覆盖了,下面是xcode中出现的警告信息:

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].
xcode的警告信息表明我们可以使用[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:]来代替[UIActionSheet showInView:].,我尝试了使用showFromTabBar来进行显示actionSheet,虽然最底下的按钮可以响应点击了,但是actionSheet的背景变成了黑色,看着很不爽;
有另外一种方法可以兼二者之所长,代码如下:

[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
参考自:
http://stackoverflow.com/questions/4447563/last-button-of-actionsheet-does-not-get-clicked

抱歉!评论已关闭.