ios - iAd横幅广告在iPhone 6/6 Plus上的位置错误

标签 ios objective-c iphone iad

我正在尝试针对iPhone 6和iPhone 6 Plus优化我的SpriteKit应用程序,但iAd标语位置错误,我无法更改。它在4英寸或3.5英寸iPhone上运行良好,但在iPhone 6和6 Plus上,横幅不在底部,而是在其上方。

另外,我一直在谷歌搜索这个问题。有很多解决方案,但是没有一个对我有用。

我在ViewController.m文件中的iAd标语使用以下代码:

//iAd
#pragma mark iAd Delegate Methods

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    CGRect screen = [[UIScreen mainScreen] bounds];
    CGFloat height = CGRectGetHeight(screen);

    banner.frame = CGRectOffset(banner.frame, 0, height-banner.frame.size.height);
    //Changing the Y-position doesn't change the banner's position

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];

    if([[NSUserDefaults standardUserDefaults] boolForKey:@"Ads_savedata"] == NO)
        [banner setAlpha:0];
    else
        [banner setAlpha:1];

    [banner updateConstraints];
    [UIView commitAnimations];
}

- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [banner setAlpha:0];
    [UIView commitAnimations];
}

对我来说,以下行似乎不影响横幅的位置。
banner.frame = CGRectOffset(banner.frame, 0, height-banner.frame.size.height);

我希望有人可以帮助我解决这个问题。感谢您的关注。

最佳答案

我猜它的屏幕宽度和高度问题。尝试一次

float SW;
float SH;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (( [[[UIDevice currentDevice] systemVersion] floatValue]<8)  && UIInterfaceOrientationIsLandscape(orientation))
{
    SW = [[UIScreen mainScreen] bounds].size.height;
    SH = [[UIScreen mainScreen] bounds].size.width;
}
else
{
    SW = [[UIScreen mainScreen] bounds].size.width;
    SH = [[UIScreen mainScreen] bounds].size.height;
}

关于ios - iAd横幅广告在iPhone 6/6 Plus上的位置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27708575/

相关文章:

ios - 具有多个 TableView 的 Split View MasterViewController

ios - 在 Storyboard中不使用导航 Controller 的情况下在 UIViewController 之间切换的最佳方法是什么?

ios - 可以从 iPhone 音乐库中读取 mp3 数据吗?

iphone - UITableView 的动画 UIView

iphone - 在 iOS 7 中移动状态栏

ios - 从数组中选择一个随机按钮

ios - 如何使用 Objective C 通过单击段按钮在 Tableview 上重新加载词典?

ios - UIButton 不调用 ImageView 中的处理函数

iphone - Twitter搜索主题标签

iphone - CMMotionManager - 专门使用 CMMotionManager 获得航向