Opening iAds in landscape app forces all orientation

My app is running in landscape mode . I don't support portrait orientation, and on all screens, if I rotate the device to portrait, everything will be in landscape as expected.

I display iAd banners and they look good, they rotate when they should along with their supervisors. Everything is fine regarding the display of the banner.

The problem is that when I click on them and the actual ad opens, the entire orientation of the app is anchored . The IAD opens in portrait mode, its position is wrong, offset by half the screen, and it messes up with the entire orientation of the app, putting it in an unsupported and weird looking portrait mode.

Any thoughts on how to avoid this?

Some information about the application:

  • iOS6
  • Landscape mode only
  • Cocos2d + UIKit for some screens
  • Integration code for iAds is standard as described in the iAds Programming Guide.
  • The root app's view controller is a simple UIViewController, no navigation controllers or anything like that.
  • It doesn't use autoplay.
+3


source to share


3 answers


I also used iAds in Cocos2d-landscape game. It works for me.

The files are located here: 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


source


You only need to customize the display of AdBannerView ads:

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

      



Thus, ads that do not support landscape should not load. Keep in mind that this will lower your fill rate.

+1


source


Well this question screwed me up for 2 days and I even gave up on iAd until I ran into the same problem with gamecenter authentication, which always opens in portrait and simultaneously virtualizes the entire orientation of the app.

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

The main idea is to let your application work in both portrait and landscape (in the informational plan of the application)

Then, in your view, the controller will adjust the selected orientation to the right, allow orientation rotation, and support both landscape and portrait.

Detailed answer here:

Gamecenter authentication only in Cocos2d terrain with CCLayer for iOS 6

Special thanks to Sylvan!

0


source







All Articles