gpt4 book ai didi

iOS 谷歌原生广告不可点击

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:31:15 25 4
gpt4 key购买 nike

以下是我的代码。当我点击 UITableViewCell 上的广告时,didSelectRowAtIndexPath 被调用并且广告未在浏览器中打开。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"NewsCell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
if ([[_arrAllNewsListing objectAtIndex:indexPath.row] isKindOfClass:[GADNativeContentAd class]]){
NSMutableDictionary *dataDict = _arrAllNewsListing[indexPath.row];

__block NativeAddCell *nativCell = [[NativeAddCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"NativeNewsContentAdCell" cellType:1];
GADNativeContentAd *ads = (GADNativeContentAd *)dataDict;
if(IsValidString(ads.headline)){
[nativCell.lblHeadline setText:ads.headline];
[nativCell.gadInstallView setHeadlineView:nativCell.lblHeadline];
}

if(IsValidString(ads.body)){
[nativCell.lblBodyText setText:ads.body];
[nativCell.gadView setBodyView:nativCell.lblBodyText];
}

if(IsArrayWithItems(ads.images) && [ads.images count] > 0){
__weak NativeAddCell *weakcell = nativCell;
[nativCell.imgView setImage:nil];
GADNativeAdImage* imageObj = (GADNativeAdImage*)ads.images[0];
if(imageObj != nil){
if(imageObj.image != nil){
[nativCell.imgView setImage:imageObj.image];
}
else if(imageObj.imageURL != nil){
[nativCell.imgView sd_setImageWithURL:imageObj.imageURL completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (image) {
weakcell.imgView.image = image;
}
if (error != nil ) {
[weakcell.imageView setImage:nil];
}
}];
}
[nativCell.gadView setImageView:nativCell.imageView];
}
}

if(IsValidString(ads.callToAction))
[nativCell.lblCallToAction setText:ads.callToAction];

[nativCell.gadView setCallToActionView:nativCell.gadView];
[nativCell.gadView setNativeContentAd:ads];

nativCell.gadView.userInteractionEnabled = NO;
return nativCell;
}
else
{
if([[[_arrAllNewsListing objectAtIndex:indexPath.row] valueForKey:@"NATIVE_AD_SPOT"] isEqualToString:@"YES"])
{

NSString *adunit = @"/XXXXX/example/native-backfill";
self.nativeAdLoader = [[GADAdLoader alloc]
initWithAdUnitID:adunit
rootViewController:self
adTypes:@[kGADAdLoaderAdTypeNativeContent]
options:nil];
self.nativeAdLoader.delegate = self;
[self.nativeAdLoader loadRequest:[GADRequest request]];
[[_arrAllNewsListing objectAtIndex:indexPath.row] setValue:self.nativeAdLoader forKey:@"AD_OBJECT"];
}
}
return cell;
}

广告加载正常,但点击事件无效。无法在谷歌文档和示例代码中找到任何解决方案。

最佳答案

如果您不使用 Google 的 .xib 文件,则必须在 GADNativeContentAd 类中调用他们的 registerAdView() 方法:

- (void)registerAdView:(UIView *)adView
clickableAssetViews:(NSDictionary<GADNativeContentAdAssetID, UIView *> *)clickableAssetViews
nonclickableAssetViews: (NSDictionary<GADNativeContentAdAssetID, UIView *> *)nonclickableAssetViews;

请在类似问题的回答中查看我的 Swift 示例:

Admob Native Advanced Not Clickable

关于iOS 谷歌原生广告不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44390019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com