如何为UITableView实现向下滑动手势?

时间:2011-06-13 10:35:24

标签: iphone tableview multi-touch swipe

我尝试了以下代码:

UISwipeGestureRecognizer *showBar = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gestureShowBar:)];
showBar.direction = UISwipeGestureRecognizerDirectionDown;
showBar.numberOfTouchesRequired = 2;
[self.tableview addGestureRecognizer:showBar];
没有运气!当我用两根手指进行滑动时,桌面视图会滚动。所以,我尝试在tableview上禁用多点触控,让superview处理手势:

UISwipeGestureRecognizer *showBar = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gestureShowBar:)];
showBar.direction = UISwipeGestureRecognizerDirectionDown;
showBar.numberOfTouchesRequired = 2;
[self.view addGestureRecognizer:showBar];

同样,它不起作用!我真的很想知道为什么桌面视图会响应两个手指滑动,虽然没有启用多点触控!

1 个答案:

答案 0 :(得分:0)

此链接描述了如何在表格行中实现捏合手势,您可以调整滑动手势而不是

查看tableviewcontroller类,其中包含handle pinch方法 http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010139

祝你好运