我有一个表格视图,其中有一个页脚视图单元格。我在页脚表视图单元格类中有一个视图。在我的VC类中,我为页脚单元格调用了委托,我将Admob视图传递给该视图,但是它没有在上面显示广告。如何在该视图上展示广告?这是我的FooterCell类代码:
@property (weak, nonatomic) IBOutlet GADBannerView *adView;
这是我在VC课堂上获得的视图,
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
FooterTVCell *footerTVCell = [tableView dequeueReusableCellWithIdentifier:@"FooterTVCell"];
//Admob Banner
bannerView_ = [[GADBannerView alloc]initWithFrame:CGRectMake(0, 450, [UIScreen mainScreen].bounds.size.width, 70)];
bannerView_.adUnitID = @"ca-app-pub-3940256099942544/2934735716"; //change this key
GADRequest *request = [GADRequest request];
//request.testDevices = @[ @"326e918015806f8d65a43e86f9e6e939" ];
request.testDevices = @[ kGADSimulatorID ];
NSLog(@"%@", request.testDevices);
bannerView_.rootViewController = self;
bannerView_.delegate = self;
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(0, 0, 25, 25);
// [button setTitle:@"Cancel" forState:(UIControlState)UIControlStateNormal];
[button setBackgroundImage: [UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(goToFun) forControlEvents:(UIControlEvents)UIControlEventTouchUpInside];
[bannerView_ addSubview:button];
[footerTVCell.adView addSubview:bannerView_];
[bannerView_ loadRequest:request];
return footerTVCell;
}
这是我运行应用程序时的看法,
最佳答案
只需检查您提到的y位置即可。
bannerView_ = [[GADBannerView alloc]initWithFrame:CGRectMake(0, **450**, [UIScreen mainScreen].bounds.size.width, 70)];
在Xcode的“调试”视图层次结构工具中进行检查。另外,如果只有一个部分,请在
viewDidLoad
中作为tableview.footerview作为adman视图。