user1120008
user1120008

Reputation: 1015

Custom Gesture on top on UITableView

I have a custom gesture that fires if the user slides his or her finger down the side of the device. It works fine in isolation, however, I want it on top of a UITableView. Whenever I slide my finger down the side, the custom gesture is masked and instead the table view scrolls. I want the table view to scroll, but in addition to that, I also want the custom gesture to fire.

Upvotes: 1

Views: 845

Answers (1)

NJones
NJones

Reputation: 27147

If you simply want to add an additional gesture recognizer to the tableview (Not overwrite existing behavior) there are relatively few hoops.

Set the delegate property of your custom recognizer to a class conforming to the <UIGestureRecognizerDelegate> protocol.

Have that class implement the following method:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
    return YES;
}

And the the cancelsTouchesInView property of your recognizer to NO.

Upvotes: 1

Related Questions