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

我想添加admob在uitableviewcontroller或uicollectionviewcontroller在屏幕的底部。 所以为此,我必须在uitableview控制器或uicolleectionview控制器的底部添加uiView(GAD BannerView)。 那我该怎么做呢? 其实我们可以在uiviewcontroller中轻松的添加uiview,但是我怎样才能在uitableviewcontroller或者uicollectionviewcontroller中添加这个呢?

是的,你也可以在UITableViewUICollectionView添加广告手机。 UITableViewController有一个属性工具栏。 您可以将AdMob添加到Toolbar ,如下所示。

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

是的,可能的。 您可以在桌面视图或collectionview的页眉或页脚视图中添加横幅广告。 像这样在表格视图

 UIView * bannerView = [[UIView alloc]initWithFrame:CGRectMake(0, 10,[[UIScreen mainScreen] bounds].size.width, 50)]; [bannerView setBackgroundColor:[UIColor clearColor]]; _tableView.tableFooterView = bannerView;