在APP更新版本之后,有一個tableView界面,請求數(shù)據(jù)之后刷新界面總是存現(xiàn)界面上移現(xiàn)象。
在網(wǎng)上搜索之后發(fā)現(xiàn)是iOS11高度默認值導致的,iOS11之后高度默認值為UITableViewAutomaticDimension 并非0。這樣在計算tableView高度的時就會和實際高度有偏差,所以才會出現(xiàn)上下偏移現(xiàn)象
@property (nonatomic) CGFloat estimatedRowHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionHeaderHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
@property (nonatomic) CGFloat estimatedSectionFooterHeight NS_AVAILABLE_IOS(7_0); // default is UITableViewAutomaticDimension, set to 0 to disable
所以可以將它們分別設置為0就可以免除刷新界面偏移效果
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;