[英]iAd positioning on iphone 5 and iphone 4 issue
我有一個spritekit
項目,我希望iAd
出現在屏幕的底部。 我用storyboard
來position
它在屏幕的底部。 唯一的問題是,如果我把它放在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
。
如果你能提供幫助,謝謝!
也許不是使用確切的數字設置位置,而是將其設置為屏幕底部減去橫幅廣告的尺寸。
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.