我有一个spritekit
项目,我希望iAd
出现在屏幕底部。我在屏幕底部使用了storyboard
到position
它。唯一的问题是,如果我将它放在iPhone 4
屏幕的底部,它会在iPhone 5
的中间结束,如果我将它放在iPhone 5
屏幕的底部,没有显示在4.我使用banner.Center
修复了这个问题一段时间但是当我更改views
时banner
没有重新加载所以它没有t显示在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
。
iad iPhone 5 Storyboard implementation
如果你能提供帮助,谢谢!
答案 0 :(得分:2)
也许不是使用确切的数字设置位置,而是将其设置为屏幕底部减去横幅广告的尺寸。
CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
banner.center = CGPointMake(160, screenHeight - bannerView_.frame.size.height);
编辑:如果您正在使用故事板,可以尝试使用约束,右键单击从iAd横幅拖动到"视图"并选择"底部空间到底部布局指南"
答案 1 :(得分:1)
做这样的事情
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);
}