2012-02-20 90 views
0

我想從橫向或縱向開始控制iAd尺寸。問題在於設備在縱向上顯示在風景上!如何處理它?謝謝iOS在縱向時會返回橫向方向

- (void)viewDidLoad 
{ 

    //iAd 

    adView =[[ADBannerView alloc] initWithFrame:CGRectZero]; 

    adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil]; 

    adView.delegate = self; 

    if (UIInterfaceOrientationIsPortrait([UIDevice currentDevice].orientation)) { 
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 
    } else { 
     adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape; 
    } 

    [self.view addSubview:adView]; 

    [super viewDidLoad]; 
} 

回答

1

您幾乎總是想在這裏使用[self interfaceOrientation]

至於爲什麼orientation不能正常工作,請注意the docs

此屬性的值始終返回0,除非取向通知已通過調用beginGeneratingDeviceOrientationNotifications啓用。

+0

就是這樣,謝謝! – Jaume 2012-02-20 18:51:48

相關問題