代码之家  ›  专栏  ›  技术社区  ›  Sivanathan

如何在视图控制器上实现admob?

  •  1
  • Sivanathan  · 技术社区  · 15 年前

    在我的应用程序中,我想实现admob,现在只有我开始了解它。所以任何一个请指导我,有什么好的教程或样品?

    4 回复  |  直到 15 年前
        1
  •  3
  •   David McGraw    15 年前

    非常简单。请按照以下指南操作: http://developer.admob.com/wiki/IPhone#AdMob_iPhone_SDK

    启动SDK后,只需执行以下操作:

    AdMobView *ad = [AdMobView requestAdWithDelegate:<your delegate>]; // start a new ad request
    ad.frame = CGRectMake(0, 432, 320, 48); // set the frame, in this case at the bottom of the screen
    [self.window addSubview:ad]; // attach the ad to the view hierarchy; self.window is responsible for retaining the ad
    
        2
  •  2
  •   Tom Irving    15 年前

    下载Admob SDK for iPhone并查看示例项目。很简单。

        3
  •  2
  •   JOM agenthunt    12 年前

    缺少一个步骤:将AdViewController对象添加到UIViewController.h/m文件中,并将其用作IB中的引用对象。否则将出现错误:

    “必须实现所需的方法

    我意识到这是一个基本的假设,但它吸引了我一分钟,我已经实现了3次AdMob在过去(使用不同的方法,请注意)。

    • 使用Interface Builder向视图添加广告
    • 打开界面生成器。
    • 添加一个对象,并将其类型更改为AdViewController。
    • 将AdViewController的视图出口设置为UIView。
    • 设置AdViewController的currentViewController出口 到拥有xib的UIViewController。
    • 编辑AdViewController.m以确保您的发布者ID和 其他选项设置正确。
        4
  •  1
  •   TigerCoding    14 年前