gpt4 book ai didi

ios - "Banner View"的帧在运行时会有所不同。 iAd 适用于最大的屏幕,但在较小的屏幕上为空白

转载 作者:行者123 更新时间:2023-11-29 12:08:52 24 4
gpt4 key购买 nike

我的应用程序快要完成了,唯一的问题是我的 iAd 横幅 View 只能在最大的屏幕上显示。我已经设置了限制,因此 iAd 可以很好地适应较小的屏幕,但是当我在除最大屏幕以外的任何尺寸上运行它时,我看到的只是一个白框。

我目前的代码是:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner {

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];

}


-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {


[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];


}

我想知道是否应该在 bannerViewDidLoadAd 中添加一行代码来说明帧大小。

我不断收到的错误是:

Frame for "banner view" will be different at run time.

大小在运行时为 (320,50),但在 Canvas 中为 (480,60)。

已导入 iAd 框架并委托(delegate)添加。如果有任何区别,它就在 ScrollView 中。

我的所有约束都很好,只是这个帧大小才是问题所在。如果我尝试更新帧,什么也不会发生。

如有任何帮助,我们将不胜感激。

谢谢。

最佳答案

听起来您在 ADBannerView 上设置了尾随和前导约束。

您的 ADBannerView 将知道它在哪个设备上,并相应地设置 ADBannerView 的尺寸。您应该让自动版式知道您希望广告出现的位置。例如,如果您希望您的 ADBannerView 位于 View 底部,那么您可以使用 Bottom Space to: Bottom Layout Guide 将其固定到 View 底部,并且将其对齐到 Align Center X to: Superview

另外,不要使用 beginAnimations:context: 方法。来自 UIView Class Reference :

Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead.

使用基于 block 的动画,您的委托(delegate)方法最终看起来像这样:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView animateWithDuration:1.0 animations:^{
banner.alpha = 1.0;
}];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView animateWithDuration:1.0 animations:^{
banner.alpha = 0.0;
}];
}

关于ios - "Banner View"的帧在运行时会有所不同。 iAd 适用于最大的屏幕,但在较小的屏幕上为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34132505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com