在使用UITableView的时候,滑动编辑的时候会调用
- (void)tableView: willBeginEditingRowAtIndexPath:以及
- (void)tableView: didEndEditingRowAtIndexPath:这两个方法,
有个问题就是滑动一次会调用一次begin,取消滑动的时候会调用了两次end,不知道是什么问题,在查找了相关的资料之后,发现有人和我一样遇到了这样的问题,于是上网查找了一下可以解决的方法,发现国外的程序员是这样解决的:
@property (weak, nonatomic) bool swipeGestureStarted
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath {
self.swipeGestureStarted = YES;
NSLog(@"begin");
}
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.swipeGestureStarted) {
self.swipeGestureStarted = NO;
(@"end");
}
}
这样就解决了调用了两次end的问题~
浙公网安备 33010602011771号