【问题标题】:Adding AdMob Interstitial ads in addition to banner ads (IOS)在横幅广告之外添加 AdMob 插页式广告 (IOS)
【发布时间】:2015-09-10 00:11:25
【问题描述】:

我的横幅广告在我的 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];

【问题讨论】:

    标签: ios admob interstitial


    【解决方案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; 导入了整个框架。

    【讨论】:

    • 谢谢丹尼尔,你说的很有道理,我已经按照你的建议做了,但它并没有消除错误 - “'GADInterstitial' 没有可见的@interface 声明选择器' initWithAdUnitId:'".
    • @user1238198 确保您的 AdMob SDK 版本为 7.2.1 或更高版本。阅读 7.2.1 的发行说明here
    • AdMob SDK 版本为 7.2.4,删除了 2 个头文件导入,但没有可见的@interface 错误仍然存​​在 - 现在开始变得更令人沮丧 ,,,,,
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多