ios - 当用户处于通话状态栏时,导航栏布局出现异常

标签 ios objective-c uiview

切换通话状态栏后,导航栏掉落。并且后面的内容落下高度为20。

我不明白为什么。

图为现场。

1

导航栏看起来像是掉落了。蓝色条落下。

从 View 层次调试器中看到,我不知道为什么蓝色条与导航栏有一段距离。

2

这是相关代码。

- (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;
}

最佳答案

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

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

更何况,为什么不用主流框架Masonry呢?

关于ios - 当用户处于通话状态栏时,导航栏布局出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52228415/

相关文章:

ios - 如何在 ScrollView 中调整 subview 的大小?

iphone - uiwebview 到 uiview

ios - FBSDKLoginBehaviorSystemAccount 不工作

iphone - 如何将我的应用程序提供给客户进行测试

objective-c - 如果包含 @try @catch block ,则不带 return 语句的 Obj-C 方法可以编译

objective-c - NSEvent addLocalMonitorForEventsMatchingMask 内存泄漏

ios - UITableView 方法 - 委托(delegate)、观察者或通知中心

ios - 如何将 View 定位为 subview ?

ios - Storyboard减少 View 之间的差距

android - 访问在线服务