UITableViewCell 内部刷新

UITableViewCell 大家都非常的熟悉,我们会经常遇到刷新cell的问题,一般我们是在外部进行刷新,今天我们封装一个内部刷新的方法。

核心方法还是使用以下方法:

- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation API_AVAILABLE((3.0));

话不多说,直接上代码:

- (void)refreshCell {
//    获取UITableView
    UITableView *table = (UITableView*)self.superview;
//    获取当前cell的indexPath
    NSIndexPath *indexPath = [table indexPathForCell:self];
//    刷新
    [table reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
原文地址:https://www.cnblogs.com/lijianyi/p/13895172.html