admob 广告接入(iOS)

很少说,看步骤。测试

  1. 下载admob广告sdk.ui

  2. 把SDK中的以下文件,除了那个文件夹,所有拖到工程里。google

  3. 导入文件(googleAD是个人上级文件夹名)#import "googleAD/GADBannerView.h"spa


  4. 加入私有属性@property(nonatmic,strong)GADBannerView *ADBanner;code

    ;orm


  5. -(void)addAD
    {
    //我是顶部广告,顶部还有导航(push)
        float y=self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height;
        float x=([UIScreen mainScreen].bounds.size.width-320)/2;
        self.ADBanner=[[GADBannerView alloc]initWithAdSize:kGADAdSizeBanner origin:CGPointMake(x, y)];
        self.ADBanner.adUnitID=MY_BANNER_ID;
        self.ADBanner.rootViewController=self;
        [self.view addSubview:self.ADBanner];
        GADRequest *request=[GADRequest request];
        request.testDevices=@[GAD_SIMULATOR_ID,MY_DEVICE_ADID];
        [self.ADBanner loadRequest:request];
    }




6.it

#define MY_BANNER_ID @"6666666666666你得广告id"io

#define MY_DEVICE_ADID @"你得测试id"class

7.test

工程设置

选择蓝色顶级项目图标》点击build setting>Other Linker Flags 下添加-ObjC

还要添加:-all_load

ok.

相关文章
相关标签/搜索