UITableView进阶,cell刷新,界面返回 保持所选cell

时间:2023-03-08 23:59:28
UITableView进阶,cell刷新,界面返回 保持所选cell

1.cell 刷新

NSIndexPath  *indexPath_1=[NSIndexPath indexPathForRow:1 inSection:0];
NSArray *indexArray=[NSArray arrayWithObject:indexPath_1]; [_tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationNone];

  

2.界面返回,保持所选cell

-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSIndexPath *selected = [_tableView indexPathForSelectedRow];
if(selected) [_tableView selectRowAtIndexPath:selected animated:NO scrollPosition:UITableViewScrollPositionNone];
}