简体   繁体   English

iad iPhone 5 Storyboard实施

[英]iad iPhone 5 Storyboard implementation

I have a paid app on the app store, and I'm trying to make a free version of the same app with ads. 我在应用商店上有一个付费应用,并且我正在尝试使用广告制作该应用的免费版本。 I was thinking about using iAds. 我当时正在考虑使用iAd。 I implemented the following code: 我实现了以下代码:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.01];
    [banner setAlpha:1];
    [UIView commitAnimations];
    CGRect adFrame = adView.frame;
    adFrame.origin.y = self.view.frame.size.height;
    adView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
    [adView setAlpha:0];
    [UIView commitAnimations];
}

And it is working great except for one thing. 除了一件事之外,它的工作效果非常好。 My app has a storyboard, and a table view controller connected to multiple view controllers inside the same storyboard. 我的应用程序具有一个情节提要,以及一个连接到同一情节提要中的多个视图控制器的表视图控制器。 I dragged a Ad Banner View to the view controller, although, I want to place it on the bottom, so when I placed at the bottom of iPhone 4 it would show almost in the middle of the iPhone 5, and when I placed on the bottom of iPhone 5 it does not show on iPhone 4 at all. 我将广告横幅视图拖动到视图控制器上,尽管我想将其放置在底部,所以当我将其放置在iPhone 4的底部时,它几乎会显示在iPhone 5的中部,而当我放置在在iPhone 5的底部,它根本不会在iPhone 4上显示。 So, I came up with an idea. 因此,我想到了一个主意。 I placed 2 Ad banner view, and made an if statement, where on the iPhone 5 the iPhone 4 banner would hide, and the iPhone 4 the iPhone 5 banner would hide. 我放置了2个广告横幅视图,并做出了if语句,其中iPhone 4横幅将隐藏在iPhone 5上,iPhone 5横幅将隐藏在iPhone 4上。 Although, I noticed that on the iPhone 4 the iAd banner always loaded up, where on the iPhone 5 it only loads sometimes. 虽然,我注意到在iPhone 4上始终会加载iAd标语,而在iPhone 5上它只会有时加载。 Also, I noticed that Apple recomends not to use more than one banner per view controller, even if it's hidden. 另外,我注意到Apple建议每个视图控制器使用不超过一个横幅,即使该横幅已隐藏。

Can somebody please help me? 有人能帮帮我吗? Please! 请! Thank you! 谢谢!

You need to set the autoresizing of the Ad banner. 您需要设置广告横幅的自动调整大小。 Just click on ad baneer in storyboard then open size inspector and set Bottom autoresing property as shown in picture below. 只需在情节提要中单击广告横幅,然后打开大小检查器并设置底部自动缩放属性,如下图所示。 Then your ad banner will almost stay in bottom. 然后,您的广告横幅几乎会停留在底部。

点击广告横幅,然后点击尺寸检查器

Click on Ad banner and then click Size inspector. 单击广告横幅,然后单击尺寸检查器。 Let me know if its working. 让我知道它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM