In anticipation for the upcoming public release of iOS 4.2, I have updated my Universal iOS App project (iAd Branch). The project will run on 3.2 and up with iAd support for iPhone and iPad (4.2 only for iPad).
I ran into some interesting hurdles while working on this update. The first of which is that adding in iAd support for a project using a UISplitViewController SUCKS! #FAIL When iAds where first offered in the 4.0 iOS they came in two different size: 320 x 50 (ADBannerContentSizeIdentifier320x50) and 480 x 32 (ADBannerContentSizeIdentifier480x32) which served their purpose since you could use iAds only on the phone. When iAd support was added for the iPad Apple was smart and deprecated those properties and added ADBannerContentSizeIdentifierPortrait and ADBannerContentSizeIdentifierLandscape, thus abstracting the dimensions that are available for any current and future devices. This unification works great on the iPhone and iPad...except for when you implement UISplitViewController on the iPad. The reason being that even though your root view or "detail" view controller are in landscape or portrait mode their widths aren't in the expected frame width for either choose of iAd. Thus you get an inaccurate display and you will an error in:
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
stating that an ad has displayed but is being obscured. In order to get around this I had to add in some padding to readjust the 'y' coordinate for the tableview's frame (only when the ad appears). Why the rotation, and only on the iPad, gets screwed up I am not sure at the moment. I created a simple, iPad only project and got the same results so there might be a bug, but until I am able to verify, my "padding" works".
It is important that if you clone/run this project that you read the debug console for iad display errors. These are relevant errors passed to the delegate method and don't have to do with my code. You will notice in the video that ad fails to load the first round. This is due to an error from Apple serving up the ad because inventory is not available. Second time is the charm.
*important - always implement delegates to handle failures
In the next few weeks I'll be adding a branch where the Universal app will have Tabbar support.