iOS APP中未显示测试插页式广告

时间:2017-04-20 13:04:34

标签: swift swift3 ads google-admob

您好我正在开发基于内容的iOS应用程序,该应用程序使用scrollview。我尝试添加测试横幅和interstital admob广告并使用CocoaPods,我添加了横幅广告和插页式测试广告,但只显示了横幅测试广告,插页式广告根本没有显示。这是代码

class ViewController: UIViewController,UIScrollViewDelegate {

var player:AVAudioPlayer?



@IBOutlet weak var bannerView: GADBannerView!
@IBOutlet var scrollView: UIScrollView!
@IBOutlet var pageControl: UIPageControl!

var interstitial: GADInterstitial!

@IBOutlet var musicButton: UIButton!

@IBOutlet var wallButton: UIButton!

@IBOutlet var shareButton: UIButton!



override func viewDidLoad() {
    super.viewDidLoad()


    bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    bannerView.rootViewController = self
    bannerView.load(GADRequest())






    self.scrollView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width,  height: self.view.frame.height)
    let scrollViewWidth : CGFloat = self.scrollView.frame.width
    let scrollViewHeight :CGFloat = self.scrollView.frame.height

    let imgOne = UIImageView(frame: CGRect(x:0, y:0,width:scrollViewWidth, height:scrollViewHeight))
    imgOne.image = UIImage(named: "b1")

     createAndLoadInterstitial()


    let imgTwo = UIImageView(frame: CGRect(x:scrollViewWidth, y:0,width:scrollViewWidth, height:scrollViewHeight))
    imgTwo.image = UIImage(named: "b2")

    let imgThree = UIImageView(frame: CGRect(x:scrollViewWidth*2, y:0,width:scrollViewWidth, height:scrollViewHeight))//*2 means the position of the scrollview
    imgThree.image = UIImage(named: "b3")



    let imgFour = UIImageView(frame: CGRect(x:scrollViewWidth*3, y:0,width:scrollViewWidth, height:scrollViewHeight))
    imgFour.image = UIImage(named: "b4")


    self.scrollView.addSubview(imgOne)
    self.scrollView.addSubview(imgTwo)
    self.scrollView.addSubview(imgThree)
    self.scrollView.addSubview(imgFour)

fileprivate func createAndLoadInterstitial(){

    interstitial = GADInterstitial(adUnitID:"ca-app-pub-3940256099942544/4411468910")
    let request = GADRequest()
    request.testDevices = [ kGADSimulatorID ]
    interstitial.load(request)



}

func alertView(_alertView: UIScrollView,willDismissWithButtonIndex buttonIndex:Int){

    if interstitial.isReady{

    interstitial.present(fromRootViewController: self)

    } else {
    print("Ad wasn't ready")

    }


}

1 个答案:

答案 0 :(得分:0)

我尝试了您的广告单元ID,这可能是与Admob帐户相关的问题,请尝试在Admob帐户设置中设置高eCPM值。