@interface
é¨åã§iAd.h
ãã¤ã³ãã¼ããã¾ãã
#import <iAd/iAd.h> @interface ViewController() <ADBannerViewDelegate> { } @property (weak, nonatomic) ADBannerView *adView; @end
viewDidLoadã¡ã½ãã
ã§ADBannerViewãçæãã¦viewã«è¿½å ãã¦ãã¾ãã
- (void)viewDidLoad { // ããã ä¸ç¥ ããã // ããã¼åºåãå ¥ãã self.adView = [[ADBannerView alloc] init]; self.adView.delegate = self; // åºåãåä¿¡ã§ãããåãããªãã®ã§ã¢ã«ãã¡å¤ã0ã«ãã¦é ãã¦ãã self.adView.alpha = 0.f; [self.view addSubview:self.adView]; }
ADBannerViewDelegateããªã²ã¼ã
ãå®è£
ãã¾ããoptionalãªã®ã§ããªã²ã¼ããç¨æããªãã¦ãã¢ããªãã¯ã©ãã·ã¥ããããã¾ããããå
ã»ã©ã®ADBannerViewã表示ãããããã®ã³ã¼ããbannerViewDidLoadAd:ã¡ã½ãã
ã«å
¥ãã¦ãã¾ãã
// iAdã®åºåã®èªã¿è¾¼ã¿ãå®äºããå - (void)bannerViewWillLoadAd:(ADBannerView *)banner { } // iAdã®åºåã®èªã¿è¾¼ã¿ãå®äºãã - (void)bannerViewDidLoadAd:(ADBannerView *)banner { self.adView.alpha = 1.f; } // iAdããã®åºåã®åä¿¡ã«å¤±æãã - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error { }
ã·ãã¥ã¬ã¼ã¿ã§ã®å®è¡ã§ãã®ã§ãã¹ãåºåã表示ããã¾ãã