Jack.Right Jack.Right -3 years ago 92
iOS Question

Is it possible to add UIView (Admob) in uitableviewcontroller or in uicollectionviewcontroller

I want to add admob in uitableviewcontroller or in uicollectionviewcontroller at the bottom of screen. So for that I have to add uiView (GAD BannerView) at the bottom of uitableview controller or uicolleectionview controller. So how can I do this?
Actually we can add uiview easily in uiviewcontroller but how can I add this in uitableviewcontroller or uicollectionviewcontroller?

Answer Source

Yeah you can also add Ad Mob in UITableView or UICollectionView.UITableViewController have a one property toolbar. You can add AdMob to Toolbar as below.

    [self.navigationController setToolbarHidden:NO];
    self.banner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    self.banner.adUnitID = @"ca-app-pub-XXXXXXXX/XXXXXXXXX";
    self.banner.rootViewController = self;
    [self.navigationController.toolbar addSubview:self.banner];

    GADRequest *request;
    [self.banner loadRequest:request];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download