我試圖發現左輕掃,在開始所以加入到我的tableview:檢測向左滑動的單元格中的tableView
//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)
}
它只有在桌面視圖沒有向下滾動的情況下才有效,這意味着在向下滾動之後,我檢測到的檢測位置是錯誤的,因此如果我嘗試添加一些側面菜單,它沒有定位正確。
如果我在開始時檢查這個權利,不滾動,它很好。
這是爲什麼?
SwTableviewCell實現了可滑動的內容視圖。這將幫助你在單元格https://github.com/CEWendel/SWTableViewCell上添加滑動條 – vijeesh