Objective c 当为纵向时,iOS返回横向方向

Objective c 当为纵向时,iOS返回横向方向,objective-c,ios,xcode,cocoa-touch,iad,Objective C,Ios,Xcode,Cocoa Touch,Iad,当从横向或纵向开始时,我试图控制iAd的大小。问题是,当它在纵向上时,设备会告诉我们它在横向上!如何处理?多谢各位 - (void)viewDidLoad { //iAd adView =[[ADBannerView alloc] initWithFrame:CGRectZero]; adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifier

当从横向或纵向开始时,我试图控制iAd的大小。问题是,当它在纵向上时,设备会告诉我们它在横向上!如何处理?多谢各位

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

您几乎总是想在这里使用
[self interface-orientation]

关于
定向
不起作用的原因,请注意:

此属性的值始终返回0,除非通过调用
BegingeratingDeviceOrientationNotifications
启用了方向通知


你确定它是在告诉你它在陆地空间上还是根本不在人像上,就像你被设置为只识别人像一样。模拟器可能返回nil,如本线程中所述: 您使用的是模拟器还是设备