在 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];
}
最后我禁用了 Bitcode。并将 ATS(应用程序传输层安全设置)添加到 plist 文件中 任何人请告诉我发生了什么问题,我该如何解决这个问题。 错误日志在这里
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setAdUnitID:]: unrecognized selector sent to instance 0x7f88bb51e090'
最佳答案
确保您的 bannerView 已在 Storyboard中分配 GADBannerView 类。
您可以在 Storyboard 中选择您的横幅 View 并转到自定义类部分并在类选项中分配 GADBannerView。
这对我有用。
关于ios - Google Admob 无法使用 Objective-C 运行 Xcode 7.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34497532/