LoginSignup
3
4

More than 5 years have passed since last update.

admob を簡単に埋め込むスクリプト

Posted at

admobの埋め込みを毎回コピペして面倒だったので、もうちょっと簡単にした。

-(void)addAdmobOn:(UIViewController *)viewController
{

    GADBannerView *bannerView_;

    bannerView_ = [[GADBannerView alloc]
                   initWithFrame:CGRectMake(0,
                                            0.0,
                                            GAD_SIZE_320x50.width,
                                            GAD_SIZE_320x50.height)];
    bannerView_.adUnitID = AD_ID;


    GADRequest *request = [GADRequest request];
    request.testing = YES;
    bannerView_.rootViewController = viewController;

    [bannerView_ loadRequest:request];

    [viewController.view addSubview:bannerView_];

}

こんな感じのAdmobクラスを作っておいて、あとは、それぞれのViewControllerで、

[[Admob alloc] addAdmobOn:self];

こんなかんじで呼ぶだけ。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4