UITableViewCell 的那些事

1、刷新某一section

NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
[self.mainTableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];

2、刷新某一cell

NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[self.mainTableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];

3、获取cell上某个sender的indexPath

- (void)touchButton:(id)sender{
    UIView *temView = [sender superview];
    UITableViewCell *cell = (UITableViewCell *)[temView superview];
    NSIndexPath *indexPath = [self.mainTableView indexPathForCell:cell];
    NSLog(@"section :%ld row :%ld",(long)indexPath.section,(long)indexPath.row);
}

你可能感兴趣的:(UITableViewCell 的那些事)