我在 UITableView 上使用滑动手势。我试图在向左滑动时对 TableViewCell 执行操作。我注意到正确的单元格被刷了,但由于某种原因,它似乎激活了一个随机的其他单元格。
我怀疑它与指针有关?我对内存指针不是很好,所以任何帮助都会很棒。处理滑动的代码是:
- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)gestureRecognizer
{
// Get location of the swipe
CGPoint location = [gestureRecognizer locationInView:self.requestTableView];
// Get the corresponding index path within the table view
NSIndexPath *indexPath = [self.requestTableView indexPathForRowAtPoint:location];
// Check if index path is valid
if(indexPath)
{
//Get the cell out of the table view
requestCell *cell = (requestCell *)[self.requestTableView cellForRowAtIndexPath:indexPath];
NSLog(@"%@", [cell.IDLabel text]);
cell.sendingImage.hidden = false;
cell.activityIndicator.hidden = false;
cell.requestorLabel.hidden = true;
cell.dueDateLabel.hidden = true;
cell.IDLabel.hidden = true;
cell.priorityImage.hidden = true;
}
}