简体   繁体   中英

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. 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. 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. Although, I noticed that on the iPhone 4 the iAd banner always loaded up, where on the iPhone 5 it only loads sometimes. Also, I noticed that Apple recomends not to use more than one banner per view controller, even if it's hidden.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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