繁体   English   中英

iAd在模拟器上有效,但在设备上崩溃(ipad)

[英]iAd works on simulator but crash on device(ipad)

我正在尝试将iAd集成到我的应用中,这是我的工作

  1. 通过Xcode 5.1创建单个视图应用(设备类型为Universal )。
  2. 将iAd.framework添加到我的项目中。
  3. 在ViewController.h中导入<iAd/iAd.h>
  4. 添加self.canDisplayBannerAds = YES; 在viewDidLoad方法中。
  5. 在iPhone和iPad模拟器上编译并运行该应用程序

该应用程序在两个模拟器上均能正常运行,我可以在应用程序底部看到横幅。

但是,当我在iPad(运行IOS 6.1)上对其进行测试时,该应用程序崩溃了,这就是我得到的。

2014-04-19 19:25:56.409 TestiAd[12771:907] -[ViewController setCanDisplayBannerAds:]: unrecognized selector sent to instance 0x1fd7b620
2014-04-19 19:25:56.413 TestiAd[12771:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController setCanDisplayBannerAds:]: unrecognized selector sent to instance 0x1fd7b620'
*** First throw call stack:
(0x336442a3 0x3b4e497f 0x33647e07 0x33646531 0x3359df68 0xfb125 0x3546b595 0x354abd79 0x354a7aed 0x354e91e9 0x354ac83f 0x354a484b 0x3544cc39 0x3544c6cd 0x3544c11b 0x371555a3 0x371551d3 0x33619173 0x33619117 0x33617f99 0x3358aebd 0x3358ad49 0x354a3485 0x354a0301 0xfb3a5 0x3b91bb20)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

我在SO上有很多类似的问题,但是其中许多与在iPad上以可计算模式运行iPhone应用程序有关,但事实并非如此,我正在Universal应用程序上进行测试。

问题出在iOS版本上。
Doc中canDisplayBannerAds在iOS7中引入,在iOS6中不存在。
因此,您可能想做:

if ([self respondsToSelector:@selector(setCanDisplayBannerAds:)])
    self.canDisplayBannerAds = YES;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM