Reputation: 956
I have a really weird issue, and it might be hard to explain, but I appreciate any help or suggestions on it.
I have a base view (View B) that has a UIGestureRecognizer that detects left and right gestures.
On top of View B, I have several small views (View C) that are covering the entire view. (Think of it as a calendar).
On each View C I have a tap gesture recognizer, and a long press gesture recognizer. On the tap gesture I display a UIAlertView.
So here's the problem:
I can tap View C and then swipe View B, and the View B swipe event fires before the UIAlertView displays. This crashes my app, because when View B is removed with the swipe event and since View C is on top of View B they are removed as well, and the alertView:clickedButtonAtIndex: is not reached at all.
Does anyone have any ideas on how to prevent the swipe from happening before the UIAlertView displays? Thanks for the help!
Upvotes: 1
Views: 633
Reputation: 7340
You may want to try making a global BOOL
variable in the .h file that says if the tap event is registered or not. In the method you call when a tap is registered, set the variable to NO
, and in your method you call when a swipe is registered, check to see if the BOOL
variable is YES
or NO
, and if it's NO
, that means a tap has been registered, and you should not proceed with the swipe method. Then, simply set the BOOL
variable to YES
after the UIAlertView
has been resigned. Hope that helps!
Upvotes: 1
Reputation: 5765
As you said, C Views entirely cover View B. Therefore, the swipe gestures on B should not be registered unless the alert has been displayed. You can add B's gesture recognizer in (void)didPresentAlertView:(UIAlertView *)alertView;
.
And then in alertView:clickedButtonAtIndex:
, you can remove B's gesture recognizer.
HTH,
Akshay
Upvotes: 1