[英]How do I make my iAd banner appear at bottom of screen?
我有以下代码,允许我将它放在顶部。 我希望它出现在底部。
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view addSubview:adView];
任何帮助将不胜感激。
更新 - @ larsacus指出这是4.2+:
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView.frame;
adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
adView.frame = adFrame;
[self.view addSubview:adView];
我在SO上的第一个答案:)
为什么不使用adView的'center'属性? 如果主视图的尺寸是viewWidth和viewHeight:
//at the bottom of view,centered
adView.center=CGPointMake(viewWidth/2, viewHeight-adView.frame.size.height);
//at the top, right corner ;)
adView.center=CGPointMake(viewWidth-adView.frame.size.width/2, adView.frame.size.height);
干杯
这是帮助我将视图移到底部的原因:
adFrame.origin.y = self.view.frame.size.height;
adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
然后,使用Storyboard忽略标准iAd横幅视图未到达屏幕边缘。 将iAd横幅设置为居中,然后根据需要将其移动到靠近底部。 没有其他宽度设置(没有前导或尾随设置)
我从superview底部的8个像素看起来很好,但我选择了iAd横幅和UIController View之间的像素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.