Search code examples
objective-cioscocoa-touchios4uiactionsheet

UIActionSheet will not act until buttons are tapped twice in iOS 4


I have a UIActionSheet which I create with the following code.

 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];

The code is working on iOS 5.0 fine. The issue is in 4.0. I have to tap twice on the buttons of the UIActionSheet to dismiss it! Anyone got this issue before?


Solution

  • Thank you all for your help but the problem was that the ibaction was called two times in ios4! So i searched in stackoverflow and i have found this

    if(sender.state != UIGestureRecognizerStateRecognized) return;

    I have putted the above code in my ibaction and it worked!!!

    Thank you again i really appreciate your help! Hope this helps someone else because i have been looking into it for hours.