在 ViewController.h 我的代码是
#import <UIKit/UIKit.h>
@class GADBannerView;
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet GADBannerView *addView;
@end
我的代码是 ViewController.m 文件
@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];
}
最后我禁用了位码。并在 plist 文件中添加了 ATS(应用程序传输层安全设置)任何人请告诉我发生了什么问题以及我该如何克服这个问题。错误日志在这里
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setAdUnitID:]: unrecognized selector sent to instance 0x7f88bb51e090'