Reputation: 369
In ViewController.h my code is
#import <UIKit/UIKit.h>
@class GADBannerView;
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet GADBannerView *addView;
@end
And ViewController.m File my code is
@import GoogleMobileAds;
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.addView.adUnitID = @"ca-app-pub-9210017787755331/6998637808";
self.addView.rootViewController = self;
GADRequest *request = [GADRequest request];
request.testDevices = @[
@"2077ef9a63d2b398840261c8221a0c9a" // Eric's iPod Touch
];
[self.addView loadRequest:request];
}
And Finally I have Disabled Bitcode. And Added ATS(Application Transport layer Security Settings ) into plist file Anybody Please tell me what the problem is happening and how can i overcome the problem. Error Log is here
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setAdUnitID:]: unrecognized selector sent to instance 0x7f88bb51e090'
Upvotes: 1
Views: 293
Reputation: 11
Be sure that your bannerView has assigned in the storyboard the GADBannerView class.
You can select your banner view in the storyboard and go to custom class section and assigne GADBannerView in the class option.
This works for me.
Upvotes: 1
Reputation: 644
Your code seems OK but if your getting this error it means that your addView
variable doesn't have a adUnitId
property which means it's not behave like GADBannerView
.
In Google's example everything happens in .m file. In your code some AdMob imports in .h file and some in .m file. The issue might be related with the importing the header in wrong place. Try to do it like exactly as Google's.
Upvotes: 0