是否可以在uitableviewcontroller或uicollectionviewcontroller中添加UIView(Admob)

问题描述:

我想在uitableviewcontroller或屏幕底部的uicollectionviewcontroller中添加admob。因此,我必须在uitableview控制器或uicolleectionview控制器的底部添加uiView(GAD BannerView)。那我该怎么做呢?
实际上我们可以在uiviewcontroller中轻松添加uiview但是如何在uitableviewcontroller或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?

是的你也可以在 UITableView UICollectionView 中添加Ad Mob。 UITableViewController 有一个属性工具栏。您可以将AdMob添加到工具栏,如下所示。

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];