touchesBegan:在UITableView中

时间:2015-02-22 14:44:46

标签: ios uitableview uiview

我需要为添加为UITableViewCell子视图的UIView实现拖放功能。我通过使用touchesBegan:touchesMoved:events来根据Apple的MoveMe示例捕获拖动。

这是在单元格中添加的视图:

enter image description here

gradientview是单元格的子视图。我只需要移动白色矩形(白色框是橙蓝色渐变视图的子视图)。我的问题是,在向上或向下拖动几个像素之后,tableview开始滚动。 Horizo​​ntaly没关系。似乎tableView在一定量的拖动后捕获拖动。我需要阻止垂直滚动,直到拖动为止。

是否有解决方案可以防止这种情况发生?

1 个答案:

答案 0 :(得分:1)

行。我最终使用了UIPanGestureRecognizer。这似乎阻止了下面的tableview。

- (void)move:(UIPanGestureRecognizer*) recognizer {
CGPoint translation = [recognizer translationInView:self];
[recognizer setTranslation:CGPointMake(0, 0) inView:self];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
                                     recognizer.view.center.y + translation.y);

}