2012-02-20 92 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

相关问题