簡體   English   中英

iAd橫幅廣告在iPhone 6/6 Plus上的位置錯誤

[英]iAd banner position is wrong on iPhone 6/6 Plus

我正在嘗試針對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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM