2015-09-06 101 views
2

我有横幅广告在我的iOS应用程序中成功地工作,但由于无法摆脱错误,我正在努力添加插页式广告的代码: - “没有可见的@interface 'GADInterstitial'声明选择器'initWithAdUnitId:'“。除了横幅广告(IOS)之外,还添加了AdMob插页式广告

我是新手开发人员,我确信这是一个简单的错误。任何人都可以帮忙吗?

我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]; 

回答

1

确保您的AdMob SDK版本7.2.1或更高版本。该release notes为7.2.1状态:

新增GADInterstitial initWithAdUnitID:和弃用GADInterstitial init

因此initWithAdUnitID:不适用于7.2.1以前的AdMob SDK版本。

另外,从头文件中删除#import "GADBannerView.h"#import "GADRequest.h"。您已经使用@import GoogleMobileAds;导入整个框架。

+0

谢谢丹尼尔,你说的话有道理,我按照你的建议做了,但它没有摆脱错误 - “GADInterstitial没有可见的@interface声明选择器'initWithAdUnitId:'”。 – user1238198

+0

@ user1238198确保您的AdMob SDK版本是7.2.1或更高版本。阅读7.2.1的发行说明[此处](https://developers.google.com/admob/ios/rel-notes) –

+0

AdMob SDK的版本为7.2.4,并删除了2个头文件导入,但“无可见” @界面错误仍然存​​在 - 现在开始得到更多的沮丧,,,,, – user1238198