3

Opening iAds in landscape application applications all orientation

 2 years ago
source link: https://www.codesd.com/item/opening-iads-in-landscape-application-applications-all-orientation.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Opening iAds in landscape application applications all orientation

advertisements

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:

  • 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.

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

}


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK