For everyone who is looking for the Swift version of the code.
- I created a new UIView within the first section of the Tableview Cell. This UIView has no constraints or a width/height because this was not possible to be set on this top position within the Storyboard.
Additionally i added the following code in my viewDidLoad() it worked for me by using swift:
var bannerView: GADBannerView!
addBannerViewToView(bannerView)
bannerView.adUnitID = "ca-app-pub-XXXXXXXX/XXXXXXXXX"
bannerView.rootViewController = self
navigationController?.toolbar.addSubview(bannerView)
bannerView.load(GADRequest())
bannerView.delegate = self
view.exerciseAmbiguityInLayout()
And this within my class:
func addBannerViewToView(_ bannerView: GADBannerView)
{
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
view.addConstraints(
[NSLayoutConstraint(item: bannerView,
attribute: .bottom,
relatedBy: .equal,
toItem: bottomLayoutGuide,
attribute: .top,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: bannerView,
attribute: .centerX,
relatedBy: .equal,
toItem: view,
attribute: .centerX,
multiplier: 1,
constant: 0)
])
}