Google-Mobile-Ads-SDK banners in interface builder with handy delegate callbacks.
Switch branches/tags
Nothing to show
Clone or download
Latest commit e11b1e4 Jan 14, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Oct 24, 2013
GVGoogleBannerView.h Add contentURL property to the GADRequest Aug 5, 2014
GVGoogleBannerView.m Add contentURL property to the GADRequest Aug 5, 2014
GVGoogleBannerView.podspec 1.4.0 Aug 5, 2014
LICENSE Initial commit Oct 24, 2013
README.md Update README.md Jan 14, 2016
b_ad_close.png Commit 1.0 Oct 24, 2013
b_ad_close@2x.png Commit 1.0 Oct 24, 2013

README.md

GVGoogleBannerView

Badge w/ Version Badge w/ Platform No Maintenance Intended

Google-Mobile-Ads-SDK banners in interface builder with handy delegate callbacks.

Normally requesting a banner from Google's Mobile Ads SDK involves code like this:

- (void)viewDidLoad {
  [super viewDidLoad];

  // Create a banner of the standard size
  self.bannerView = [[DFPBannerView alloc] initWithAdSize:kGADAdSizeBanner];

  // Configure
  self.bannerView.adUnitID = MY_AD_UNIT_ID;
  self.bannerView.rootViewController = self;

  // Add to view
  [self.view addSubview:self.bannerView];

  // Load the ad, enable testing on simulator
  GADRequest *request = [GADRequest request];
  request.testDevices = @[GAD_SIMULATOR_ID];
  [self.bannerView loadRequest: request];
}

Using GVGoogleBannerView however, you simply drag a UIView into your interface, set its size to the required banner size, change its class to GVGoogleBannerView and set its googleBannerViewDelegate outlet to the view controller.

Your view controller must then implement the only required delegate method:

- (NSString *)googleBannerViewAdUnitID {
  return MY_AD_UNIT_ID;
}

GVGoogleBannerView also (optionally) adds a close button to the banner, makes it a lot easier to provide extra targeting parameters and has easy delegate callbacks for when banners are opened or closed. You can for example add a content inset to your tableview, scrollview or collectionview:

- (void)googleBannerViewOpened:(GVGoogleBannerView *) googleBannerView {
    UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, googleBannerView.frame.size.height, 0);
    self.collectionView.contentInset = insets;
    self.collectionView.scrollIndicatorInsets = insets;
}

- (void)googleBannerViewClosed:(GVGoogleBannerView *)googleBannerView {
    self.collectionView.contentInset = UIEdgeInsetsZero;
    self.collectionView.scrollIndicatorInsets = UIEdgeInsetsZero;
}