admob肖像模式工作不景观

时间:2012-09-10 03:39:11

标签: objective-c ios ipad cordova

我想知道当用户将ipad置于横向模式而不是移植时,我如何获得调整高度

此代码适用于Portrait,但我需要做些什么才能让它在横向上正常工作。我尝试过谷歌搜索和其他博客,但所有尝试都失败了。

- (void) viewDidLoad
{


    bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    CGFloat screenXPos = (screenWidth /2);
    CGFloat screenYPos = screenHeight - 60;
    [bannerView_ setCenter:CGPointMake(screenXPos, screenYPos)];
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];

    // Initiate a generic request to load it with an ad.
    GADRequest *request = [GADRequest request];
    // remove this line when you are ready to deploy for real

    [bannerView_ loadRequest:request];





    [super viewDidLoad];
}

1 个答案:

答案 0 :(得分:0)

试试这个,

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        //your frame for landscape
    } else {
        //your frame for portrait
    } 
}
相关问题