mea36
mea36

Reputation: 746

How do you add gestures to a UITableViewController?

I want to implement right-to-left and left-to-right gestures on a view that inherits from UITableViewController. I have the code for the gestures implemented in another view (UIViewController) and it works.

It does't seem like touchesBegan is even getting called.

Does anyone know know to do this?

Thanks

Upvotes: 1

Views: 1077

Answers (1)

drawnonward
drawnonward

Reputation: 53669

It depends on the SDK version. In 3.2, use UIGestureRecognizer. Prior to 3.2 use touchesBegan and friends. This is especially true when dealing with a UIScrollView because UIGestureRecognizer will cancel touchesBegan. So if you want to be forwards and backwards compatible you have to do both with a UIScrollView.

For your particular case, use UISwipeGestureRecognizer or UIPanGestureRecognizer. You will have to implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: to prevent the UIScrollView from canceling your gesture recognizers.

UITableViewController -> UITableView : UIScrollView

Upvotes: 2

Related Questions