我在右侧滑动时切换 UITableViewCell 上的背景图像。问题是如果我添加[taskManager reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];
它只会切换一次但不会切换回来。那么这是为什么呢?什么会让这不会发生?这是整个方法代码。
- (void)handleSwipeRight:(UISwipeGestureRecognizer *)gestureRecognizer {
CGPoint location = [gestureRecognizer locationInView:self.taskManager];
NSIndexPath *indexPath = [self.taskManager indexPathForRowAtPoint:location];
[taskManager reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationRight];
UIImage *notCkDone = [UIImage imageNamed:@"UITableViewCellCheckmark"];
UIImage *isCkDone = [UIImage imageNamed:@"UITableViewCellCheckmarkDone"];
UIImage *notBgDone = [UIImage imageNamed:@"UITableViewCell"];
UIImage *isBgDone = [UIImage imageNamed:@"UITableViewCellDone"];
UITableViewCell *cell = [taskManager cellForRowAtIndexPath:indexPath];
if (indexPath) {
if (cell.imageView.image == notCkDone) {
cell.imageView.image = isCkDone;
cell.backgroundView = [[UIImageView alloc] initWithImage:isBgDone];
} else {
cell.imageView.image = notCkDone;
cell.backgroundView = [[UIImageView alloc] initWithImage:notBgDone];
}
cell.textLabel.textColor = [UIColor colorWithRed:0.0/0.0 green:0.0/0.0 blue:0.0/0.0 alpha:1.0];
}
}