objective-c - 在 iOS 4 中,只有点击按钮两次,UIActionSheet 才会起作用

标签 objective-c ios cocoa-touch ios4 uiactionsheet

我有一个使用以下代码创建的 UIActionSheet

 UIActionSheet *popupQuery2 = [[UIActionSheet alloc] initWithTitle:@"Choose" 
                                                          delegate:nil 
                                                 cancelButtonTitle:@"Cancel" 
                                            destructiveButtonTitle:@"Accept Friendship" 
                                                 otherButtonTitles:@"Do not accept friendship",@"Check profile", nil];
popupQuery2.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery2 setDelegate:self];
popupQuery2.tag=3;
[popupQuery2 showInView:self.view.superview];
[popupQuery2 release];

该代码在 iOS 5.0 上运行良好。问题出在4.0中。我必须点击 UIActionSheet 的按钮两次才能将其关闭!有人以前遇到过这个问题吗?

最佳答案

谢谢大家的帮助,但问题是 ibaction 在 ios4 中被调用了两次!所以我在 stackoverflow 中搜索,找到了这个

if(sender.state!= UIGestureRecognizerStateRecognized) 返回;

我已将上述代码放入我的 ibaction 中并且它有效!!!

再次感谢您,我非常感谢您的帮助!希望这对其他人有帮助,因为我已经研究了几个小时。

关于objective-c - 在 iOS 4 中,只有点击按钮两次,UIActionSheet 才会起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8899882/

相关文章:

ios - 带有普通列表的 UITableView,但使部分标题像分组列表

ios - BOOL 在 objective-c 中为值 0 返回 YES?

objective-c - iOS 多任务应用启动

ios - 如何将 LDAP "jpegPhoto"转换为 NSString 到 UIImageView

ios - 奇怪的段控制功能发生

ios - 如何始终在 Obj c 中看到 Tableview 的滚动条?

ios - 使用 subview 修改 UIImage

iphone - iPhone 3.0 与 2.2.1 上的 KVO 存在问题

ios - 我可以使用滑动删除来使用 titleForDeleteConfirmationButtonForRowAtIndexPath 滑动来执行其他操作吗?

iphone - UITableView 不接受触摸传递