1

Good day!

I have a trouble with placing a bannerView in my app. Its a static TableViewController, and the bannerView is supposed to be at the bottom of the screen. I did everything as it is said in 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)
        ]
    )

This is how it loads now, slightly below the view:

enter image description here

My guess problem is in the last Constraint, bottomLayoutGuide seems to be leading somewhere when it should not. When I remove last constraint it appears right below NavigationBar.

enter image description here

This problem does not occur on iOS 11+, only on previous versions.

Konstantin
  • 197
  • 3
  • 12
  • what is the issue can you elabrate more? – KKRocks Aug 27 '18 at 11:33
  • The issue is that according to constraints from post 1, the banner should be precisely at the bottom of the view, I should not be scrolling down to see it. It loads perfectly on simulator with iOS 11, but not on 10, 9.. etc. – Konstantin Aug 27 '18 at 11:36
  • replace bottom constraint with this : NSLayoutConstraint(item: bannerView, attribute: .bottom, relatedBy: .equal, toItem: bottomLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0) – KKRocks Aug 27 '18 at 11:38
  • see this : https://stackoverflow.com/questions/31651022/how-to-create-layout-constraints-programmatically – KKRocks Aug 27 '18 at 11:43
  • This did not help :( – Konstantin Aug 27 '18 at 12:50
  • see this : https://stackoverflow.com/questions/45534851/toplayoutguide-and-bottomlayoutguide-deprecated-in-ios-11 – KKRocks Aug 27 '18 at 12:52

0 Answers0