无法在方向更改时调整AdMob视图的大小

时间:2011-12-06 05:52:16

标签: ios view admob uiinterfaceorientation autoresize

我到目前为止尝试的是,在viewDidLoad中,我调用了

self.bannerView.autoresizingMask=UIViewAutoresizingFlexibleWidth;

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)newInterfaceOrientation duration:(NSTimeInterval)duration {
    if (newInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || newInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        self.bannerView.frame=CGRectMake(0.0,
                                         0.0,
                                         480.0,
                                         GAD_SIZE_320x50.height);
    }
    // Position the UI elements for portrait mode
    else {
        self.bannerView.frame=CGRectMake(0.0,
                                         0.0,
                                         GAD_SIZE_320x50.width,
                                         GAD_SIZE_320x50.height);
    }
}

这些都不适合我。

2 个答案:

答案 0 :(得分:1)

嗯,我不认为AdMob的广告素材可以在横向播放时适应屏幕的大小。因此,尽管您正在扩展视图的框架以适应,但我认为广告本身将保持相同的大小。

这意味着您仍然会看到广告进入方向更改,它看起来大小相同(请务必在willAnimateRotationToInterfaceOrientation:方法中再次请求广告)。

答案 1 :(得分:0)

您无需进行任何移动,但必须为adMovView设置正确的rootViewController。

如果您使用视图控制器模型,请在每个自定义视图控制器中添加行

adMobView.rootViewController = viewController;

其中viewController - 您应用的根视图控制器。

不要像这样编码

adMobView.rootViewController = self; 

在自定义视图中!

相关问题