1.
automaticallyAdjustsScrollViewInsets
self.edgesForExtendedLayout = UIRectEdgeNone;
if ([self respondsToSelector:@selector(automaticallyAdjustsScrollViewInsets)]){
self.automaticallyAdjustsScrollViewInsets = NO;
}
//如果还是有20px偏移,只能在以下方法设置了- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (_viewModel.pageType == 2) { //等级 _tableView.contentOffset = CGPointMake(0, 0); return; } if (_tableView.contentOffset.y < 0) { _tableView.contentOffset = CGPointMake(0, 0); }
ios11
self.automaticallyAdjustsScrollViewInsets = NO; if ([_tableView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } else { // Fallback on earlier versions } }
http://www.jianshu.com/p/8440a3d181c9
http://www.jianshu.com/p/75fd23bb5286