2012-12-31 40 views
0

我已經看到其他問題,但他們似乎沒有幫助...當橫幅被按下時,iAd將不起作用?

我有我的視圖控制器在我的標籤欄應用程序的底部的iAd橫幅。 我想在它沒有廣告時將其隱藏起來,但在它發佈時將其透露。

下面是從視圖控制器我的代碼將其打開或關閉,根據蘋果公司的例子:

- (void)configureAdAnimated:(BOOL)animated 
{ 
    CGRect viewFrame = self.mainView.frame; 
    CGRect bannerFrame = adBannerView.frame; 

    self.adBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 

    if (adBannerView.bannerLoaded) { 
     viewFrame.size.height -= adBannerView.frame.size.height; 
     bannerFrame.origin.y = viewFrame.size.height; 
     self.adIsVisible = YES; 
    } 
    else { 
     bannerFrame.origin.y = viewFrame.size.height + bannerFrame.origin.y; 
     self.adIsVisible = NO; 
    } 

    [UIView animateWithDuration:animated ? 0.25 : 0.0 animations:^{ 
     self.mainView.frame = viewFrame; 
     [self.mainView layoutIfNeeded]; 
     adBannerView.frame = bannerFrame; 
    }]; 

} 

它時不時拋出隨機誤差(一些未知的,有的喜歡「的廣告資源不可用」等),並熄滅時,它必須,但說到上我不能點擊它,有一個黑色的空間上面,像這樣:

iAd doesn't open, and the banner has a black space above it...

我已經設置當前內容大小標識符,委託(= self)等。

我該怎麼做才能使它工作? 請告訴我,如果您需要更多代碼,更多信息等。 謝謝!

+1

有一個很好的視頻如何處理iAds看到這個答案:http://stackoverflow.com/questions/4350824/iad-on-webview-iphone/7794535#7794535 – Joe

回答

1

嘗試通過在單一視圖應用程序中實現iAd而不是標籤式佈局來簡化調試。

請注意,黑色空間看起來與iAd尺寸相同。這應該讓你知道發生了什麼。

+0

我不得不刪除「self.mainView .frame = viewFrame;「和「[self.mainView layoutIfNeeded];」現在它工作了! – Macro206