1

我在每第二行之后在 TableView 中添加一个 AdUnit 时遇到问题。我发现有人在尝试另一个问题,但我无法在 Swift 中进行。似乎什么都没有出现,甚至连我的牢房都没有中断表明第二个牢房发生了什么事。任何帮助是极大的赞赏。

var nativeExpressAdView: GADNativeExpressAdView!
let request = GADRequest()

  override func viewDidLoad() {
    super.viewDidLoad()
     nativeExpressAdView.adUnitID = “{adUnitIDNumber}”
     nativeExpressAdView.rootViewController = self
  }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let post = posts[(indexPath as NSIndexPath).row]

    if (0 == (indexPath.row % 2)) {
        if let cell = tableView.dequeueReusableCell(withIdentifier: "PostCell") as? FeedPostCell {

            cell.contentView.addSubview(nativeExpressAdView!)
            nativeExpressAdView.loadRequest(request)

        } else {
            return FeedPostCell()

        }

    } else {

        if let cell = tableView.dequeueReusableCell(withIdentifier: "PostCell") as? FeedPostCell {
            cell.postImg.image = UIImage(named:"placeholderImg")
            cell.delegate = self

            if let img = feedViewController.imageCache.object(forKey: post.imageUrl as NSString) {
            cell.configureCell(post, img: img)
            } else {
            cell.configureCell(post)
            }
            return cell
        } else {

        return FeedPostCell()
        }

    }
    return FeedPostCell()
}
4

0 回答 0