ios - Google Admob 无法使用 Objective-C 运行 Xcode 7.2

标签 ios objective-c admob xcode7.2

在 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/

相关文章:

objective-c - 为什么使用 CoreText 绘图看起来与使用 UILabel 不同?

iphone - 在 iPhone 上横向全屏播放 YouTube,纵向内嵌播放 YouTube

iphone - 旋转:我收到错误 "wait_fences: failed to receive reply: 10004003"

java - 无网络时如何更改 ADMOB 广告的背景颜色

android - React Native Expo生成apk返回错误: should NOT have additional property 'googleMobileAdsAppId'

ios - TabController 上的 ContainerView 创建 Phantom Tab

ios - 为什么我的 Xcode 界面生成器显示红色 block 并且无法呈现

objective-c - vec4 内核例程上的编译器错误

ios - 如何在 iOS 中按预定时间发送短信/电子邮件

ios - Google Consent SDK - 链接器错误