5
votes

This is still a relatively new topic so not sure how many people have got to implement iAd on iPad (iOS4.2.1).

But basically, I get the iAd banner to appear in landscape mode (and it appears correctly). The only problem is when I click the "Test Advertisement" it shows the test advertisement in portrait mode. I.e., the device is still in landscape but the text and iad box itself that says "this confirms that test ads are running correctly" is sideways.

Is this normal? has anyone else experience this? It almost seems like an apple bug but I'm not sure...

3
The code I posted in my answer [here][1] [1]: stackoverflow.com/a/24536352/1627959 might help.Tim
In my case it's the other way around. I have a "portrait only" iPad app, however the test ad shown when tapping the banner is always in landscape mode.Jonny
You need to mark the bottom answer as correct. The top one simply states that ads change when live and is also 5 years old. The post by Chris has an actual solution to the problem.Albert Renshaw

3 Answers

3
votes

This happens to me, too. Apple's test ads on iPhone and iPad are portrait only. Real advertisements probably will support landscape mode.

1
votes

the ADBannerView's requiredContentSizeIdentifiers is defaulted to have Landscape AND Portrait. If you are using landscape only, you must make a new NSSet with ADBannerContentSizeIdentifierLandscape

iAdView.requiredContentSizeIdentifiers = [NSSet setWithObjects:ADBannerContentSizeIdentifierLandscape, nil];

After doing this, the test ad with show up correctly.

1
votes

I just had the same issue and in my case it was caused by not setting the rootViewController in the app delegate. Instead I had just added the controller's view directly to the window.

This behaviour can be reproduced by making a single change to the BasicBanner example from Apple's iAdSuite.

In AppDelegate.m change the line:

self.window.rootViewController = tvc;

to:

[self.window addSubview:tvc.view];

and the advertisement will always appear in portrait. Change the line back to setting the rootViewController and the ad will rotate appropriately.

Setting the rootViewController appears to be necessary for the iAd module to get device orientation notifications.

Along the way I noticed that the ad, or at least the test ad, only responds to the device orientation and does not respect the controller's interfaceOrientation at the time that the ad is invoked. If you run BasicBanner without the above mistake and with device laying flat and the app in landscape mode, the ad will appear in portrait and will not reorient to landscape until you tip up the device. The simulator behaviour is equally inconsistent.

I don't know whether this weakness is particular to just the test ad or all iAd ads.