[英]iAd positioning on iphone 5 and iphone 4 issue
我有一个spritekit
项目,我希望iAd
出现在屏幕的底部。 我用storyboard
来position
它在屏幕的底部。 唯一的问题是,如果我把它放在iPhone 4
屏幕的底部,它最终会在iPhone 5
的中间,如果我把它放在iPhone 5
屏幕的底部,它就不会显示在4。
我通过使用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;
}
我发现这个链接,但是当我上的广告点击storyboard
和大小检查时, autosizing
部分显示不出来....我认为这与事实,即它是一个做SpriteKit
project
。
如果你能提供帮助,谢谢!
也许不是使用确切的数字设置位置,而是将其设置为屏幕底部减去横幅广告的尺寸。
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
banner.center = CGPointMake(160, screenHeight - bannerView_.frame.size.height);
编辑:如果您正在使用故事板,可以尝试使用约束,右键单击从iAd横幅拖动到“视图”并选择“底部空间到底部布局指南”
做这样的事情
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.