我正在尝试在滑动时实现表格视图单元格删除,就像在 AnyDo 应用程序中一样。有什么帮助???
我的代码:
我正在使用手势识别器
- (UISwipeGestureRecognizer *)swipeRightRecognizer
{
if (!_swipeRightRecognizer)
{
_swipeRightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
_swipeRightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
}
return _swipeRightRecognizer;
}
向单元格添加手势:
[cell.contentView addGestureRecognizer:self.leftGestureRecognizer];
处理滑动。
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer indexPath: (NSIndexPath *)index
{
if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft)
{
//Table View deletion code. + Line to be drawn on cell, move that cell to the bottom of the table with animaiton.
}
}