簡體   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