ios - iphone 5 和 iphone 4 问题上的 iAd 定位

标签 ios objective-c xcode storyboard iad

我有一个 spritekit我想要的项目iAd出现在屏幕底部。我用了storyboardposition它在屏幕的底部。唯一的问题是如果我把它放在 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 .

iad iPhone 5 Storyboard implementation

如果你能帮忙,谢谢!

最佳答案

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

CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;
banner.center = CGPointMake(160, screenHeight - bannerView_.frame.size.height);

编辑:如果您使用 Storyboard ,也许您可​​以尝试使用约束,右键单击从 iAd 横幅拖动到“ View ”并选择“底部空间到底部布局指南”

enter image description here

关于ios - iphone 5 和 iphone 4 问题上的 iAd 定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25635948/

相关文章:

ios - 无法在 WatchKit Extension (CocoaPods) 中使用 Parse 库

objective-c - 在 OS X 中打开和创建窗口

ios - Objective C 框架动画

ios - 查找基础 View Controller 名称

objective-c - 仅使用 NSBundle 插入 Xib 的两个按钮。仍然显示TableView

ios - 如何获取我的蓝牙设备服务 UUID? swift

iphone - 强制 MPMoviePlayerController 横向播放

ios - 当后台请求完成时通知 swift

ios - 具有自动布局的 UICollectionViewCell : how to get rid of UIView-Encapsulated-Layout-Height?

ios - 将 xcode 分析器与葫芦测试框架集成