2012-09-10 42 views
0

我想知道如何獲得高度時,用戶將iPad的景觀模式,而不是portate的AdMob portate模式下工作而不是橫向

這個代碼適用於人像,但我需要什麼做以調整讓它也適用於景觀。我試過谷歌搜索和其他博客,但所有的嘗試都失敗了。

- (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]; 
} 

回答

0

試試這個,

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) { 
     //your frame for landscape 
    } else { 
     //your frame for portrait 
    } 
} 
相關問題