【问题标题】:NavigationBar Layout has an exception when user has in call status bar当用户在通话状态栏中时,导航栏布局出现异常
【发布时间】:2018-09-07 19:12:12
【问题描述】:

在我切换通话状态栏后,导航栏消失。而后面的内容高度为 20 。

我不知道为什么。

图为现场。

看起来导航栏掉了。蓝条掉下来。

从视图层级调试器看,不知道为什么蓝条和导航栏有距离。

这里是相关代码。

- (void)viewWillLayoutSubviews{
      self.blueBar.translatesAutoresizingMaskIntoConstraints = NO;
      [super viewWillLayoutSubviews];
      [self.blueBar.topAnchor constraintEqualToAnchor: self.view.topAnchor].active = YES;
      [self.blueBar.leadingAnchor constraintEqualToAnchor: self.view.leadingAnchor].active = YES;
      [self.blueBar.trailingAnchor constraintEqualToAnchor: self.view.trailingAnchor].active = YES;
      [self.blueBar.heightAnchor constraintEqualToConstant: 75].active = YES;
      ......
}


-(UIView *)blueBar{
    if(!_blueBar){
        _blueBar = [[UIView alloc] init];
        _blueBar.backgroundColor = [UIColor blueColor];
    }
    return _blueBar;
}

【问题讨论】:

    标签: ios objective-c uiview


    【解决方案1】:

    通话时状态栏高度从20变为40。我发现你使用tableView,所以试试这个:

    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    

    还有,为什么不用主流框架Masonry

    【讨论】:

    • 苹果的布局约束(第二版)非常好用。在斯威夫特。
    猜你喜欢
    • 1970-01-01
    • 2023-03-11
    • 2012-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多