I am creating an app on cocos2d.
i config the iAd but I don’t know my app is crashing on device but when I run app on simulator it works fine.
Error:
[ADBannerView initWithAdType:]: unrecognized selector sent to instance
Code:
- (void)createAdBannerView {
Class classAdBannerView = NSClassFromString(@"ADBannerView");
if (classAdBannerView != nil) {
_adBannerView = [[classAdBannerView alloc] initWithAdType:ADAdTypeBanner];
[_adBannerView setPosition:ccp([[CCDirector sharedDirector] winSize].width/2, -33)];
[_adBannerView setDelegate:self];
[[[CCDirector sharedDirector] view] addSubview:_adBannerView];
}
}
initWithAdType requires iOS 6.0 or above. If you are testing on an iOS 5.x device, you’ll see the crash. Use the old way of initializing ADBannerViews (e.g., initWithFrame) on older devices.
This is the iOS 6.0 declaration for initWithAdType:
To support the old iOS5 way of creating an iAd banner, you’ll need to add:
Example code: