繁体   English   中英

iAd定位于iphone 5和iphone 4问题

[英]iAd positioning on iphone 5 and iphone 4 issue

我有一个spritekit项目,我希望iAd出现在屏幕的底部。 我用storyboardposition它在屏幕的底部。 唯一的问题是,如果我把它放在iPhone 4屏幕的底部,它最终会在iPhone 5的中间,如果我把它放在iPhone 5屏幕的底部,它就不会显示在4。
我通过使用banner.Center解决了这个问题一段时间,但是当我更改viewsbanner不会重新加载,因此它不会出现在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实现

如果你能提供帮助,谢谢!

也许不是使用确切的数字设置位置,而是将其设置为屏幕底部减去横幅广告的尺寸。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM