Frage

I am trying to integrate iAd to my app, here is what I do

  1. Create a single view app(devices type universal) by Xcode 5.1.
  2. Add iAd.framework to my project.
  3. Import <iAd/iAd.h> in ViewController.h
  4. Add self.canDisplayBannerAds = YES; in viewDidLoad method.
  5. 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.

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) 

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.

War es hilfreich?

Lösung

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;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top