我的横幅广告在我的iOS应用程序中成功运行,但我正在努力添加插页式广告的代码,因为我无法摆脱错误: - “没有可见的@interface for'GADInterstitial'声明选择器'initWithAdUnitId:'”
我是一名新手开发者,我确信这是一个简单的错误。有人可以帮忙吗?
我的viewcontroller.h看起来像这样: -
#import <UIKit/UIKit.h>
#import "GADBannerView.h"
#import "GADRequest.h"
@import GoogleMobileAds;
@class GADBannerView, GADRequest;
@class GADInterstitial, GADRequest;
@interface GenTeamViewController : UIViewController
<GADBannerViewDelegate, GADInterstitialDelegate> {
GADBannerView *bannerView_;
GADInterstitial *interstitialView_;
NSString *teamName;
UILabel *teamLabel;
}
@property(nonatomic, strong) GADInterstitial *interstitial;
@property (nonatomic, strong)GADBannerView *bannerView;
-(GADRequest *)createRequest;
,
,
,
@end
视图控制器.m看起来像: -
- (void)viewDidLoad
{
[super viewDidLoad];
self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"xxxxxxxxx"];
GADRequest *request = [GADRequest request];
// Requests test ads on test devices.
request.testDevices = @[@"xxxxxxxxx"];
[self.interstitial loadRequest:request];
答案 0 :(得分:1)
确保您的AdMob SDK版本为7.2.1或更高版本。 7.2.1状态的release notes:
添加了
GADInterstitial initWithAdUnitID:
并弃用了GADInterstitial init
。
因此initWithAdUnitID:
不适用于早于7.2.1的AdMob SDK版本。
另外,从头文件中删除#import "GADBannerView.h"
和#import "GADRequest.h"
。您已使用@import GoogleMobileAds;
导入整个框架。