Thursday, April 21, 2011

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

From stackoverflow
  • 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
    
    mea36 : I'm running 3.1.2, do you know where I can get 3.2?
    mea36 : Or is there any way to do this without the gestureRecognizer?
    David Dunham : You can get 3.2 by buying an iPad. Or wait a few days for 4.0…

0 comments:

Post a Comment