到目前为止我尝试的是,在 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);
}
}
这两个都不适合我。
最佳答案
嗯,我认为 AdMob 的广告素材在横向时无法拉伸(stretch)以适应屏幕尺寸。因此,尽管您拉伸(stretch)了 View 的框架以适应,但我认为广告本身将保持相同的尺寸。
这意味着您仍然应该看到广告在方向发生变化时出现,只是看起来大小相同(请确保在 willAnimateRotationToInterfaceOrientation: 方法中再次发出广告请求才能看到这一点)。
关于ios - 无法在方向更改时调整 AdMob View 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8395917/