[英]iAd positioning on iphone 5 and iphone 4 issue
I have a spritekit
project where I want iAd
to appear at the bottom of the screen. 我有一个
spritekit
项目,我希望iAd
出现在屏幕的底部。 I used the storyboard
to position
it at the bottom of the screen. 我用
storyboard
来position
它在屏幕的底部。 The only problem is if I put it at the bottom of an iPhone 4
screen it ends up in the middle of the iPhone 5
, and if I put it at the bottom of the iPhone 5
screen it doesn't show up on the 4. 唯一的问题是,如果我把它放在
iPhone 4
屏幕的底部,它最终会在iPhone 5
的中间,如果我把它放在iPhone 5
屏幕的底部,它就不会显示在4。
I fixed this problem for a while by using banner.Center
but when I change views
the banner
doesn't reload so it doesn't appear on the iPhone 4
screen. 我通过使用
banner.Center
解决了这个问题一段时间,但是当我更改views
, banner
不会重新加载,因此它不会出现在iPhone 4
屏幕上。
#pragma mark iAd Delegate Methods
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(@"SUCCESS");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
if (device == 4) {
banner.center = CGPointMake(160, 455);
}
if (device == 5) {
banner.center = CGPointMake(160, 543);
}
adIsThere = YES;
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"ERROR");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
adIsThere = NO;
}
I found this link but when i click on the ad on the storyboard
and on the size inspector, the autosizing
part doesn't show up.... I think it has to do with the fact that its a SpriteKit
project
. 我发现这个链接,但是当我上的广告点击
storyboard
和大小检查时, autosizing
部分显示不出来....我认为这与事实,即它是一个做SpriteKit
project
。
iad iPhone 5 Storyboard implementation iad iPhone 5 Storyboard实现
If you can help, Thanks! 如果你能提供帮助,谢谢!
Maybe instead of setting the position with an exact number, set it to the bottom of the screen minus the size of your banner ad. 也许不是使用确切的数字设置位置,而是将其设置为屏幕底部减去横幅广告的尺寸。
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
banner.center = CGPointMake(160, screenHeight - bannerView_.frame.size.height);
edit: maybe you can try to use constraints if you're using storyboard, right click drag from your iAd banner to the "view" and select "Bottom Space to Bottom Layout Guide" 编辑:如果您正在使用故事板,可以尝试使用约束,右键单击从iAd横幅拖动到“视图”并选择“底部空间到底部布局指南”
Do something like this 做这样的事情
if ([[UIScreen mainScreen] bounds].size.height==480) //iPhone 4
{
banner.center = CGPointMake(160, 455);
}
else if ([[UIScreen mainScreen] bounds].size.height==568) //iPhone 5
{
banner.center = CGPointMake(160, 543);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.