iOS 10.3.3,tableView布局问题,tableView意外偏移

时间:2018-10-11 03:36:16

标签: ios user-interface layout version-control

在iOS 10.3.3中,tableView布局存在问题,如下图所示,tableView具有意外的偏移量。

image

代码如下:

- (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中,这是正常的。

如何解决?

0 个答案:

没有答案