问题描述
我正在尝试将iAd集成到我的应用中,这是我的工作
I am trying to integrate iAd to my app, here is what I do
- 创建单个视图应用(设备类型通用)Xcode 5.1。
- 将iAd.framework添加到我的项目中。
- 导入
< ViewController.h中的iAd / iAd.h>
- 在viewDidLoad中添加
self.canDisplayBannerAds = YES;
方法。 - 在iPhone和iPad模拟器上编译并运行应用程序
- Create a single view app(devices type universal) by Xcode 5.1.
- Add iAd.framework to my project.
- Import
<iAd/iAd.h>
in ViewController.h - Add
self.canDisplayBannerAds = YES;
in viewDidLoad method. - Compile and run the app on iPhone and iPad simulator
应用效果很好在模拟器上,我可以看到我的应用程序底部的横幅。
The app works well on both simulator and I can see the banner at the bottom of my app.
但是当我在iPad上测试它(运行IOS 6.1)时,应用程序崩溃了,这里是我得到的。
But when I test it on my iPad(running IOS 6.1), the app crashes, Here is what I got.
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应用程序有关,但事实并非如此,我正在通用应用程序上进行测试。
I have got lots of similar question on SO, but many of them were related to running iPhone app as computable mode on iPad, but this is not the case, I am testing on a Universal app.
推荐答案
问题出在iOS版本上。
来自: C和isplayBannerAds
是在iOS7中引入的,在iOS6上不存在。
所以,您可能想要这样做:
The issue is on the iOS version.
From the Doc: canDisplayBannerAds
is introduced in iOS7 and doesn't exist on iOS6..
So, you may want to do :
if ([self respondsToSelector:@selector(setCanDisplayBannerAds:)])
self.canDisplayBannerAds = YES;
这篇关于iAd在模拟器上运行但在设备上崩溃(ipad)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!