2010-11-23 40 views
1

更新12/16/2010:當使用4.2 SDK定位4.0設備時,看起來類似的問題...您的應用程序將崩潰如果您使用Interface Builder創建廣告橫幅視圖,請立即進行。弱連接iAd框架並在代碼方面重新創建廣告橫幅實施是修復。由於這個線程雷Wenderlich:http://www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-appiAds iOS 4.2中傳遞給ADAdSizeForBannerContentSize的內容大小「無效內容大小」

---

嗨,我只是想使用的是iOS 4.2 SDK(最終)和指定的iOS 4.0設備運行我的應用程序,即使我的應用程序編譯很好,我立即得到這個錯誤時運行...


*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'Invalid content size 'ADBannerContentSizePortrait' passed to 
ADAdSizeForBannerContentSize' 
... 

我想...


- (void)viewDidLoad { 
    self.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50; 
} 

...但沒有運氣,仍然得到相同的崩潰錯誤。在IB中,它看起來像「大小」的唯一選項是「肖像,風景,或兩者」,我猜iOS 4.0不是一個粉絲。

任何人有什麼建議?非常感謝。

回答

0

你必須改變

- (void)viewDidLoad { self.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50; }

- (void)viewDidLoad { self.bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait //or landscape }

你已經被廢棄了什麼意思它不再支持iOS 4.2的

+0

謝謝 - 我最初在IB中設置橫幅大小,這似乎也通過移除並重新添加iAd框架到項目中來解決。 – taber 2010-11-27 04:33:59

0

看起來,如果你刪除的iAd框架和使用重新添加「添加現有框架......」這能解決問題...怪異。希望這可以幫助別人。

+0

只有現在的問題是,我一直沒能在模擬器(4.0和4.2)成功加載廣告......得到這個錯誤在bannerView:didFailToReceiveAdWithError:「錯誤域= ADErrorDomain代碼= 3「的操作廣告資源不可用「' – taber 2010-11-23 03:55:16

+0

另一個說明 - 這實際上在設備上工作...只是不在模擬器中。我認爲這可能是一個路由器或小史瑞奇相關的問題。現在全部設置! – taber 2010-11-23 03:57:38

6

的這爲我工作。看起來,低於4.2的os版本仍然希望廢棄內容大小標識符,至少在Interface Builder中創建ADBannerView時。作爲預防措施,我也有iAd框架弱連接。我希望這對某人有幫助,並且非常感謝這個網站上的偉大社區提供所有精彩的信息和洞察力!

// if the current version of the os is less than 4.2, use the old way of defining the banner size 
if ([[[UIDevice currentDevice] systemVersion] compare:@"4.2" options:NSNumericSearch] == NSOrderedAscending) { 

    adBanner.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50]; 

    adBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50; 

    NSLog(@"below 4.2"); 

} else { 

    adBanner.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait]; 

    adBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait; 

    NSLog(@"4.2 or above"); 

} 
0

在問題的「更新」中找到的答案是正確的。請注意,在撰寫本文時,thread by Ray Wenderlich需要更新,因爲它使用了不推薦的iAd常量。否則,它是解決這個問題的一個非常好的資源。