3
votes

My app runs in landscape mode. I do not support portrait orientation and, in all of the screens, if I rotate the device to portrait, everything is, as expected, in landscape.

I am displaying iAd banners and they look good, they rotate when they should along with their superviews. Everything is ok regarding banner display.

The problem is that when I tap on them and the actual ad is opened, the whole app orientation gets screwed. The iAD is opened in portrait mode, its position is wrong, offset to half of the screen, and it messes with the whole app orientation, taking it to an unsupported and weird looking portrait mode.

Any thoughts on how to avoid this?

Some app details:

  • iOS6
  • Landscape mode only
  • Cocos2d + UIKit for some screens
  • The integration code for iAds is standard, as explained on the iAds programming guide
  • The app root view controller is a simple UIViewController, no navigation controllers or anything like that.
  • It doesn't use autolayout.
3
Did you find an answer to this somewhere? Not sure here but I have an app in landscape mode, and even tapping on a landscape type ad opens the ad page content in portrait mode (for instance, it slides in from right, when app is displayed in landscape right mode).Jonny
Nope, I've never found the answer.Lio
Have the same problem :( is there any solution ?ColdSteel

3 Answers

1
votes

Me also used iAds in Cocos2d-landscape game. For me its working.

Here is files hosted: Download

-(void)showBannerView
{
    _adBannerViewIsVisible = true;
    AppController * myDelegate = (((AppController*) [UIApplication sharedApplication].delegate));
    [myDelegate.navController.view addSubview:self.adBannerView];

    if (self.adBannerView)
    {
        [UIView animateWithDuration:0.5
                              delay:0.1
                            options: UIViewAnimationCurveEaseOut
                         animations:^
         {
             CGSize s = [[CCDirector sharedDirector] winSize];

             CGRect frame = self.adBannerView.frame;
             frame.origin.y = s.height - frame.size.height;
             frame.origin.x = (s.width/2.0f - frame.size.width/2.0f);

             self.adBannerView.frame = frame;
         }
                         completion:^(BOOL finished)
         {
         }];
    }

}
1
votes

You need to set the AdBannerView to display landscape-ads only:

adBannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierLandscape];
adBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;

This way, ads that don't support landscape should not be loaded. Be aware that this will result in a drop of your fill-rate.

0
votes

Well this issue screwed me up for 2 days and I even gave up on iAd untill I ran to the same issue with gamecenter authentication, that always opens in portrait and screws the whole orientation for the app in the same manner .

However the solution for the game center I found almost immediately in google search. I tried to apply the same solution for iAd and it worked.

the main idea is to let your app to run in both portrait and landscape (in info plist of the app)

Then in your view controller to set the preffered orientation to landscape right , allow rotation of orientations and support both landscape and portrait.

The detailed answer is here:

Gamecenter authentication in landscape only Cocos2d with CCLayer for iOS 6

Special thanks to Sylvan !