iOS 10.3.3 , tableView 布局有问题,如下图,tableView 有一个突然的偏移。
代码如下:
- (void)viewWillLayoutSubviews{
self.tableView.translatesAutoresizingMaskIntoConstraints = NO;
[super viewWillLayoutSubviews];
[self.tableView.bottomAnchor constraintEqualToAnchor: self.view.bottomAnchor constant: -52].active = YES;
[self.tableView.leadingAnchor constraintEqualToAnchor: self.view.leadingAnchor].active = YES;
[self.tableView.trailingAnchor constraintEqualToAnchor: self.view.trailingAnchor].active = YES;
[self.tableView.topAnchor constraintEqualToAnchor: self.view.topAnchor constant: 75].active = YES;
}
设置了 self.automaticallyAdjustsScrollViewInsets
, 不起作用。
- (void)viewDidLoad {
[super viewDidLoad];
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
}
在 iOS 11.4, 布局正常。
怎样解决呢?
重新编辑下问题吧,不知道是不是刷新出了问题不,如果是刷新出了问题,可以使用