2016-08-06 36 views
1

ich will in UITableViewCell Native Anzeigen Express zeigen und ich habe mit benutzerdefinierten Klasse benutzerdefinierte Zelle erstelltIntegration von AdMob Native Ads Express in uitableviewcell?

import UIKit 
import GoogleMobileAds 

class GoogleAdsCell: UITableViewCell { 

    @IBOutlet weak var NativeAds: GADNativeExpressAdView! 


    override func awakeFromNib() { 


     super.awakeFromNib() 


     // Initialization code 


     NativeAds.layer.cornerRadius = 2 


     NativeAds.layer.shadowOffset = CGSizeMake(0, 0) 


     NativeAds.layer.shadowOpacity = 1.0 


     NativeAds.layer.shadowRadius = 6 


     NativeAds.clipsToBounds = true 

    } 

} 

und in der Viewcontroller bei cellForRowAtIndexPath

 let adsGoogleCell1 = tableView.dequeueReusableCellWithIdentifier("GoogleAdsCell") as! GoogleAdsCell 


      adsGoogleCell1.NativeAds.adUnitID = "ca-app-pub-3940256099942544/2562852117" 

      adsGoogleCell1.NativeAds.rootViewController = self 

      let request = GADRequest() 

      request.testDevices = [kGADSimulatorID] 

      adsGoogleCell1.NativeAds.loadRequest(request) 




      return adsGoogleCell1 

es funktioniert FIRST und die Anzeigen auftauchten Aber nach einiger Zeit ist es verschwunden?

+0

hallo, ist dieses Problem behoben? –

Antwort

1

Ich habe genau dasselbe Problem konfrontiert und gelöst, indem ich folgendes offizielles Beispiel von GitHub folgte. Hier ist es https://github.com/googleads/googleads-mobile-ios-examples/tree/master/Swift/admob/NativeExpressExample

Und das ist vollständigen Code für meine cellForRowAt Methode

let cell = tableView.dequeueReusableCell(withIdentifier: "MyTableBannerCell", for: indexPath) as! NewsDetailTableViewCell 

cell.newsBottomBannerContainer.adUnitID = "native_express_ads_banner_id" 
cell.newsBottomBannerContainer.rootViewController = self 

let videoOptions = GADVideoOptions() 
videoOptions.startMuted = true 
cell.newsBottomBannerContainer.setAdOptions([videoOptions]) 

let request = GADRequest() 
request.testDevices = [kGADSimulatorID] 
cell.newsBottomBannerContainer.load(request) 

return cell 
+0

du bist genial bro! Danke vielmals. –