iOS tableView的特殊用法

1.刷新某一行

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:3 inSection:0];//行号 [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 2. 刷新某一组 NSIndexSet *indexSet = [[NSIndexSet alloc]initWithIndex:1]; // 组数 [self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
3.刷新从第0组开始的两组
NSIndexSet *indexSet = [[NSIndexSet alloc]initWithIndexesInRange:NSMakeRange(0, 2)]; [self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];

4.滚动到某一行
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_currentRow inSection:0] animated:YES scrollPosition:UITableViewScrollPositionMiddle];

5.自定义headerView时

要在viewDidLayoutSubviews 方法中重写headerView高度,才准确


 

猜你喜欢

转载自www.cnblogs.com/ioszhangjunyan/p/12410066.html