How to detect simultaneous swipe and touch-ended - ios

Is it possible to detect direction of swipe and simultaneously detect release of finger from screen? When I use gesture recognizer from Object library, it works only swipe or only touchesEnded, but not simultaneously.

Set cancelsTouchesInView to NO on your swipe gesture recognizer. If you're working from interface builder, it's the Canceled in View checkbox.

Related

Gesture Recognisers and Touch Began for a View in Swift

I have a View. In that view I added a gestureRecogniser for Pan,Rotate and Pinch. Recogniser takes small amount of time to detect it as a Gesture. But When I add touchesBegan function It detects the touch when I touch the finger to the screen without any delay. Any suggestion to Solve. I need GestureRecogniser for Pinch and Rotate the View. For Panning I need to use TouchesBegan function. How can i Keep both those things in a View

Cannot swipe to switch UICollectionView page if you begin gesture on a cell

I have a UICollectionView that contains a single UIButton in each cell. I've discovered it's difficult to swipe between the horizontal pages because if you touch down on a cell to begin the swipe, the UIButton touch events are triggered instead of allowing the swipe gesture to occur. I do have Delays Content Touches enabled for the collection view. What can I do to solve this so that it will recognize the page pan swipe gesture when you begin swiping on a cell? Perhaps the amount of delay can be increased before it recognizes a UIControl event?
Note that I do need to preserve the touch events for the buttons - I need to know when these events occur: TouchDown, TouchDragEnter, TouchCancel, TouchDragExit, and TouchUpInside.
Without the knowledge of whether you add the gesture recognizer in storyboard or by code, I can only suggest that you can try to creates a dependency relationship between the cell's gesture recognizer and the other gesture recognizer.
- (void)requireGestureRecognizerToFail:(UIGestureRecognizer *)otherGestureRecognizer
You have to set delaysContentTouches to YES on your UICollectionView. That way, there will be a small delay before the cells will receive a touch, and the built-in swipe recogniser can do its work.
You can also do that from the nib/storyboard by ticking the appropriate checkmark in IB:
It seems this was only a problem in iOS 8.0 (at least the simulator), as I'm no longer experiencing it in iOS 8.1.

Drag Gesture Recognizer interfere with swipe Gesture Recognizer

I have a problem about gesture recognizer. I have two gesture recognizers in my view, one added to the background superview to swipe to change background color, the other one is added to a subview which could be dragged around.
The problem is the drag gesture is interfered with the swipe. When I drag the view around, in some case, drag operation will be recognized as a swipe and trigger the swipe operation. I don't want this, I just want swipe could be recognized after finish this drag operation. This situation is more often when I drag the subview around quickly. Every time during the drag, the swipe operation will be triggered.
You need to setup your lesser UIGestureRecognizer with requireGestureRecognizerToFail: and pass your recognizer that you want to be important to it.
UIView *subview = ....
[self addSubview:subview];
[self.gestureRecognizer requireGestureRecognizerToFail:subview.gestureRecognizer];

Cancel UIGestureRecognizer if subview contains gesture?

I was originally using the UITouch methods (touchesMoved: withEvent:) in order to detect the movement in a view. Due to the fact that it seemed not to update often enough I switched to using a UIPanGestureRecognizer (though this didn't actually fix the initial problem).
After using this the touches received for movements responded no matter what it was touching (different subviews) which I actually prefer. However now I have an issue with all the subviews which have movement. I need the gesture recognizer to still move the view even while touching subviews, however if the subview also moves in this direction (left/right) I need my recognizer to cancel.
It seems like gestureRecognizerShouldBegin: might be somewhere to start, but in my case, I cannot account for all subviews.
Is it possible to make pan gesture recognizer cancel if the subview (i.e. another pan recognizer, UISlider, horizontal scrollview, etc.) touched needs to be moved in left/right directions without having to account for each subview individually?

UIWebView override swipe gesture

I have a UIWebView that loads a page that captures left/right swipe gestures. So all swipe gestures are eaten up by the UIWebView, meaning that these gestures do not work within my app.
How do I:
Prevent the UIWebView from eating the left/right gestures, but still process all other events (such as swipe up/down to scroll)
Pass a two-finger swipe through to the UIWebView as a one-finger swipe.
Even if (1) is possible, that would be excellent!
Thanks!
you can use
[self.view gestureRecognizers]
this will give you an array of the gesture recognisers from here you should be able to remove or change the action of the gesture recogniser.

Resources