【发布时间】:2015-09-25 13:16:43
【问题描述】:
我正在尝试检测左滑动,所以在开始时添加到我的表格视图中:
//swipe left
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(leftSwipe:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self.tableView addGestureRecognizer:recognizer];
然后用 :
检测单元格本身- (void)leftSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
{
CGPoint location = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
//show some menu in the cell position( its cell.frame)
}
它仅在 tableview 尚未向下滚动时才有效,这意味着在我向下滚动后,我检测到的检测位置是错误的,因此如果我尝试添加一些侧边菜单,它的位置不正确。
如果我一开始就选中这个,不滚动,效果很好。
为什么会这样?
【问题讨论】:
-
SwTableviewCell 实现了可滑动的内容视图。这将帮助您在单元格github.com/CEWendel/SWTableViewCell 上添加滑动
标签: ios objective-c uitableview