3

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.
Stefan
  • 5,203
  • 8
  • 27
  • 51
Lio
  • 4,225
  • 4
  • 33
  • 40
  • 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 Aug 16 '13 at 07:18
  • Nope, I've never found the answer. – Lio Aug 16 '13 at 12:34
  • Have the same problem :( is there any solution ? – Coldsteel48 Apr 18 '15 at 22:26

3 Answers3

1

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)
         {
         }];
    }

}
Guru
  • 21,652
  • 10
  • 63
  • 102
  • its there in text file. Download those 3 file. – Guru Feb 15 '13 at 18:30
  • It wasn't very clear how to set it up, but once I did it worked for me! Also solved my other question: http://stackoverflow.com/questions/14890479/iad-banner-not-clickable-if-banner-moves – AlexQueue Feb 16 '13 at 22:49
  • first add MyIAd.h and MyIAd.m to your project then follow this - https://docs.google.com/viewer?pid=explorer&srcid=0ByA3hGNxt2x5OEFhWUJUbDQ3clU&docid=0c9dbaa3a792247f5d652f0d5c00a8b0%7C3c4acecf31c7c880b4dce07a80cc6714&chan=EgAAAFjq%2BToqtu%2BIAunxfec7xfM0iXky%2BhdEgD8noyxs36vu&a=v&rel=zip;z8;readMe_Add+in+main+menu+cclayer.rtf – Guru Feb 17 '13 at 04:39
  • This answer is not relevant. The code deals with Banner rotation issues. As I explained above in my question, I have no problems whatsoever with banners rotating. The problem I have is when the user taps the banner and the iAds takes full screen control, screwing all the UI. – Lio Feb 18 '13 at 13:34
1

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.

patric.schenke
  • 942
  • 11
  • 19
  • Those are deprecated methods. Anyway as you said, it is not my intention to filter ads, but to fix whatever makes everything rotate and look bad. Thanks anyway! – Lio Feb 22 '13 at 12:35
  • I know they've been marked as deprecated, but Apple still has them in the guide and I can't see any useful replacement-API. On the other hand I don't believe advertisers are forced to provide ads in every available format. – patric.schenke Feb 22 '13 at 13:13
0

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 !

Community
  • 1
  • 1
Coldsteel48
  • 3,482
  • 4
  • 26
  • 43