1

I am really confused about Apple's and Xcode's documentation for iAd banner sizes. Apple says the iPhone portrait size is 320x50 here: iAd Programming Guide: Banner View Concepts.

So why is it when i drag an iAd banner in storyboard its width is 480 and its height is 66? Which I think it should be for landscape? Am I missing something?

Would it effect the banner if I adjust it to 320x50 to display the ads?

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
Nata Mio
  • 2,168
  • 3
  • 22
  • 46
  • Does your storyboard have the exact size of an iPhone? Probably not. It is tool to align your layout relative to each other. The actual size of the iAd should not really matter to you, you determine where it is positioned and add constraints for views which are e.g. 10 pixel above it - the actual size does not matter. – luk2302 Dec 28 '15 at 11:00

1 Answers1

1

Apple's iAd documentation hasn't been updated in quite sometime.

Your ADBannerView will know which device it is on and set the dimensions of the ADBannerView correctly. You should just let auto layout know where you want the ad to be. For example, if you wanted the ADBannerView to be at the bottom of the screen then pin it to the bottom of the screen with Bottom Space to: Bottom Layout Guide and align it to Align Center X to: Superview. Be sure you do not set any height, width, trailing, or leading constraints.

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
  • Is it okay if i did like : `adBannerView.frame = CGRect(x: 0, y: view.frame.height - adBannerView.frame.height, width: adBannerView.frame.width, height: adBannerView.frame.width)` i think its the same as using auto layout ? agree ? – Nata Mio Dec 28 '15 at 14:05
  • `width: adBannerView.frame.height` should probably be this `width: adBannerView.frame.width`. You don't even need to set the frame size actually. Check out a programmatic implementation of a [Shared iAd Banner](http://stackoverflow.com/a/28639200/2108547). – Daniel Storm Dec 28 '15 at 14:06
  • Ive just noticed that, edited. thanks for the reference i have already implemented a better way of it. – Nata Mio Dec 28 '15 at 14:10
  • I've found that if I don't include the leading and trailing constraints (pinning it to the edges of the view), the iAd flickers and continuously tries to reload. I also had a warning (due to a universal storyboard) that the frame width of 600 didn't match what was expected at runtime. I set the leading and trailing constraints to 999 priority, and added a width constraint of 480 with priority 1000, and ticked `Remove at build time`. – Jeff V Jan 23 '16 at 16:46