在屏幕底部放置iAd(两个方向)

时间:2011-12-18 04:46:10

标签: iphone ios ipad iad

我在IOS4.3上进行了通用应用程序(iPhone / iPad)测试。它有一个iAd,我想在两个方向位于屏幕的底部.. 以下是代码;

- (void) viewWillAppear:(BOOL)animated {
adView_.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
    adView_.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;

    CGRect adFrame = adView_.frame;
    adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height;
    adView_.frame = adFrame;

    adView_.delegate = self;
    [webView addSubview:adView_];
    [self.view bringSubviewToFront:adView_];
    self.bannerIsVisible=NO;

    [super viewWillAppear: animated];
}

现在进行定向处理,我有;

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
        self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    else
        self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    CGRect adFrame = adView_.frame;
    adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height;
    adView_.frame = adFrame;
    [webView addSubview:adView_];
    [self.view bringSubviewToFront:adView_];
    self.bannerIsVisible=NO;
}

我的问题是应用程序加载(纵向),我能够看到iAd明确位于屏幕底部。

但是一旦我将方向更改为横向,我就看不到iAd了。我看到了消息;

  

ADBannerView:警告横幅视图(0x62534a0)有广告,但可能是   模糊。此消息仅在每个横幅视图中打印一次。

我想我在willRotateToInterfaceOrientation

中做错了什么

请帮我解决问题。 谢谢。

1 个答案:

答案 0 :(得分:1)

尝试将代码移至didRotateFromInterfaceOrientation。新的几何体尚未在willRotateToInterfaceOrientation中设置。