Cocoa touch ADBannerView完整广告方向未更改

Cocoa touch ADBannerView完整广告方向未更改,cocoa-touch,iad,Cocoa Touch,Iad,我使用苹果iAd套件演示代码中的代码来实现带有标签栏控制器的横幅广告。直到最近,我才注意到测试广告变得更加丰富多彩,而不仅仅是带有“测试广告”字样的黑色矩形 然而,我现在看到,虽然横幅视图旋转良好,但整个广告仅以横向方向显示。应用程序的其余部分可以正常旋转,但无论设备处于哪个方向,完整的添加只会在横向显示 我不知道如何控制这一切 代码如下: #import "BannerViewController.h" NSString * const BannerViewActionWillBegin =

我使用苹果iAd套件演示代码中的代码来实现带有标签栏控制器的横幅广告。直到最近,我才注意到测试广告变得更加丰富多彩,而不仅仅是带有“测试广告”字样的黑色矩形

然而,我现在看到,虽然横幅视图旋转良好,但整个广告仅以横向方向显示。应用程序的其余部分可以正常旋转,但无论设备处于哪个方向,完整的添加只会在横向显示

我不知道如何控制这一切

代码如下:

#import "BannerViewController.h"

NSString * const BannerViewActionWillBegin = @"BannerViewActionWillBegin";
NSString * const BannerViewActionDidFinish = @"BannerViewActionDidFinish";

@implementation BannerViewController
{
    ADBannerView *_bannerView;
    UIViewController *_contentController;
}

- (id)initWithContentViewController:(UIViewController *)contentController
{
    self = [super init];
    if (self != nil) {
        _bannerView = [[ADBannerView alloc] init];
        _bannerView.delegate = self;
        _contentController = contentController;
    }
    return self;
}

- (void)loadView
{
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [contentView addSubview:_bannerView];
    [self addChildViewController:_contentController];
    [contentView addSubview:_contentController.view];
    [_contentController didMoveToParentViewController:self];
    self.view = contentView;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return [_contentController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

- (void)viewDidLayoutSubviews
{
    if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
        _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    } else {
        _bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    }
    CGRect contentFrame = self.view.bounds;
    CGRect bannerFrame = _bannerView.frame;
    if (_bannerView.bannerLoaded) {
        contentFrame.size.height -= _bannerView.frame.size.height;
        bannerFrame.origin.y = contentFrame.size.height;
    } else {
        bannerFrame.origin.y = contentFrame.size.height;
    }
    _contentController.view.frame = contentFrame;
    _bannerView.frame = bannerFrame;
}

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    [UIView animateWithDuration:0.25 animations:^{
        [self.view setNeedsLayout];
        [self.view layoutIfNeeded];
    }];
}

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    [UIView animateWithDuration:0.25 animations:^{
        [self.view setNeedsLayout];
        [self.view layoutIfNeeded];
    }];
}

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
    [[NSNotificationCenter defaultCenter] postNotificationName:BannerViewActionWillBegin object:self];
    return YES;
}

- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
    [[NSNotificationCenter defaultCenter] postNotificationName:BannerViewActionDidFinish object:self];
}

@end
shouldAutorotateToInterfaceOrientation:
方法中,interfaceOrientation是纵向的,并且计算结果为true。完整的广告仍在《风景》中播出


这是什么原因造成的?我如何控制它?

在沙箱模式下似乎只支持一个方向。

什么是“沙箱模式”?我见过这个词,但我不确定你在这里的意思。在这种情况下,这是否仅适用于dubug和特别构建?或者它是否存在于可交付成果中?在发布应用程序之前,即在应用程序审查和批准之前,我们进行测试,这称为沙箱模式。显然,调试和特别构建将处于沙箱模式。