iOS TableView reloadData refresh list cell jumps randomly

As shown in the figure, every time you click on 'Favorite Jobs', the list will be refreshed after modifying the favorite status, the position of the cell will move up or down, and the viewForHeaderInSection will also jump randomly.

 

Solution:

After iOS 11 Self-Sizing is automatically turned on, both contentSize and contentOffset may change. Can be disabled by

 self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;

self.estimatedSectionFooterHeight = 0;

 

Below iOS 10, you can set the precise height through the following protocol method

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(7_0);

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section NS_AVAILABLE_IOS(7_0);

 

Guess you like

Origin blog.csdn.net/smile82475/article/details/79303768