美文网首页
UITableViewCell 的那些事

UITableViewCell 的那些事

作者: 奋撸小菜鸟 | 来源:发表于2016-05-12 14:42 被阅读14次

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 的那些事

      本文链接:https://www.haomeiwen.com/subject/clfprttx.html