BottomLayoutGuide iOS 10与iOS 11

时间:2018-08-27 11:24:49

标签: ios view tableview banner safearealayoutguide

美好的一天!

在我的应用程序中放置bannerView时遇到麻烦。 它是一个静态的TableViewController,bannerView应该位于屏幕的底部。我做了Google Mobile SDK中所说的一切。

func positionBannerViewFullWidthAtBottomOfView(_ bannerView: UIView) {
    view.addConstraints([
        NSLayoutConstraint(item: bannerView,
                           attribute: .leading,
                           relatedBy: .equal,
                           toItem: view,
                           attribute: .leading,
                           multiplier: 1,
                           constant: 0),
        NSLayoutConstraint(item: bannerView,
                           attribute: .trailing,
                           relatedBy: .equal,
                           toItem: view,
                           attribute: .trailing,
                           multiplier: 1,
                           constant: 0),
        NSLayoutConstraint(item: bannerView,
                           attribute: .bottom,
                           relatedBy: .equal,
                           toItem: bottomLayoutGuide,
                           attribute: .top,
                           multiplier: 1,
                           constant: 0)
        ]
    )

这是现在加载的方式,略低于视图:

enter image description here

我的猜测问题是在最后一个约束中,bottomLayoutGuide似乎在不应该出现的情况下处于领先地位。当我删除最后一个约束时,它会出现在NavigationBar的正下方。

enter image description here

仅在以前的版本上,此问题在iOS 11+上不会发生。

0 个答案:

没有答案