2010-11-23 75 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常量。否则,它是解决这个问题的一个非常好的资源。