Tuesday 25 September 2012

iAd code is broken in iOS6


I guess many of you are using iAd banners in your free apps. With iOS6 some changes come to iAd, that you need to take care of.
The banner size constants changed already with iOS5 once, and they change again now with iOS6. At first you were using constant names like “ADBannerContentSizeIdentifier320x50″ when first iAd came, then Apple abstracted the names to terms like portrait and landscape like “ADBannerContentSizeIdentifierPortrait” and now with iOS6 Apple are dropping banner sizes out of the picture.
If you try to compile your iAd powered app for iOS6 you will most probably get several errors due to the fact that currentContentSizeIdentifier property of the banner view is now deprecated. You have two options:
  • easy temporary solution – you can quickly get your app to compile again by using a cheap cheat, add explicitly #import <iAd/iAd.h> to the files where you are accessing currentContentSizeIdentifier and the size name constants. That should get you going until you alter your app to use the new auto-layout features.
  • permanent Apple recommended solution – the way Apple recommends you handle this is to drop all references to currentContentSizeIdentifier and make your ad view auto resize so it takes the width of the screen. This way it will know the width of the screen and request the specific size banner when refreshing the banner
I guess your old apps won’t really support auto-layout out of the box so option #1 is the way to go (also you could uncheck AutoLayout in the property inspector for your XIB files, if you don’t want the automatic auto-layout functionality).
However as you know Apple is not much into supporting old technologies, so when you have time you’d need to update your apps to auto-layout!

No comments:

Post a Comment