【问题标题】:AdMob not showing ads in iOS simulatorAdMob 没有在 iOS 模拟器中展示广告
【发布时间】:2011-08-23 11:31:11
【问题描述】:

我正在尝试在应用上使用 AdMob(专为 iOS 4.0 构建)

我添加了教程http://code.google.com/mobile/ads/docs/ios/fundamentals.html 中可用的示例代码,如下(我更改了adUnitID):

// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
               initWithFrame:CGRectMake(0.0,
                                        self.view.frame.size.height -
                                        GAD_SIZE_320x50.height,
                                        GAD_SIZE_320x50.width,
                                        GAD_SIZE_320x50.height)];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"XYZ";

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];

GADRequest * request = [GADRequest request];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];

这样做没有任何反应,没有显示任何广告,并且我的 AdMob 应用页面中的请求数量不规律地增加(即:我似乎没有注意到某种模式),但最重要的是没有显示任何广告。

如果我添加以下代码:

GADRequest * request = [GADRequest request];

request.testDevices = [NSArray arrayWithObjects:
                       GAD_SIMULATOR_ID,                               // Simulator
                       nil];

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];

我收到“成功!您现在准备好穿越 App Galaxy”的默认横幅,但只有这个。

所以我的问题是:

  • 示例代码还不足以展示广告吗?为什么我从来没有看到带有示例代码的广告?
  • 据我了解,请求是指我的应用要求展示广告的次数。我也明白,并不是每个请求都得到了广告回复(否则填充率将是 100%),但我仍然没有看到广告,我做错了什么?

提前致谢。

【问题讨论】:

    标签: iphone ios admob


    【解决方案1】:

    我设置了以上所有方法。广告横幅在设备中看起来正常,但在模拟器中没有显示广告。

    我将设备 ID 设置为 GAD_SIMULATOR_ID。但它不起作用。它的委托方法没有被调用。 !!

    【讨论】:

      【解决方案2】:
        GADBannerView *bannerView = [[GADBannerView alloc]
                    initWithFrame:CGRectMake(0.0,
                                             self.view.frame.size.height -
                                             GAD_SIZE_320x50.height,
                                             GAD_SIZE_320x50.width,
                                             GAD_SIZE_320x50.height)];//Set Position
      
        bannerView.adUnitID = @"12331255421245";//Call your id
      
      // Let the runtime know which UIViewController to restore after taking
      // the user wherever the ad goes and add it to the view hierarchy.
      
      
      bannerView.rootViewController = self;
      
      [self.view addSubview:bannerView];//Your attempt to add bannerview
      
      
      // Initiate a generic request to load it with an ad.
      
      [bannerView loadRequest:[GADRequest request]];
      

      【讨论】:

        【解决方案3】:

        在设备中试用。模拟器中的应用不显示 Admob 广告。

        【讨论】:

        • 我也遇到了类似的问题,而且设备也好不到哪里去。其他建议?
        • 检查您是否注册了有效的adUnitID。如果您已经将其放置为:GADBannerView *bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - GAD_SIZE_320x50.height - 42, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; bannerView.adUnitID = MY_BANNER_AD_ID; 如果您还没有注册。入口点大概在这里:admob.com/register
        • 最终,当您运行一个新的单元 ID 时会出现延迟。几天后我再次使用它,因为没有人使用该应用程序,但现在它处于活动状态,广告出现了。
        • @rushafi 它确实会在模拟器中显示广告。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-09-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多