iAd框架在iPhone上返回错误的高度 [英] iAd frame returning wrong height on iPhone

查看:72
本文介绍了iAd框架在iPhone上返回错误的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iAd,但是当我尝试获取广告的高度以便将其放置在屏幕底部时,我会尝试将其放置在屏幕底部.仅当我以横向进入屏幕时才会出现此错误,因为广告在纵向方向上更高,并且仅在iPhone模拟器上与在ipad上一样,广告的高度相同.

I have an iAd which I am trying to position at the bottom of the screen though when I try to get the height of the ad so that I can put it at the bottom. This error only occurs when I enter the screen in a landscape orientation as the ad is taller in the portrait orientation and only on the iPhone simulator as on an ipad the ads are the same height.

我用来将添加项放在底部的方法是将广告框架的y值设置为视图高度减去广告高度.

The method I am using to put the add at the bottom is by setting the y value of the ad frame to the height of the view minus the height of the ad.

这是我当前正在使用的代码:

Here is the code that I am currently using:

- (void)viewWillAppear:(BOOL)animated
{
    CGRect adFrame = banner.frame;
    adFrame.origin.y = screenHeight - banner.frame.size.height;
    adFrame.size.width = screenWidth;
    banner.frame = adFrame;
    [banner setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth];
}

- (void)viewDidLoad 
{
    [super viewDidLoad];
    banner.frame = CGRectZero;
}

任何帮助将不胜感激.

推荐答案

我来看看

I would take a look at Apple's sample code for integrating iAD exactly how you describe, particularly in ContainerBanner/ContainerBanner/BannerViewController.m. What you are looking for is ADBannerView's - (CGSize)sizeThatFits:(CGSize)size.

CGRect adRect = CGRectZero;
CGRect contentFrame = self.view.bounds;
adRect.size = [banner sizeThatFits:contentFrame.size];
adRect.origin.y = CGRectGetHeight(contentFrame) - CGRectGetHeight(adRect);
banner.frame = adRect;

这篇关于iAd框架在iPhone上返回错误的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆