- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有这个应用程序,它有一个 admob 横幅广告和一个插页式广告。横幅在所有屏幕上运行良好。
插页式广告只应在一个屏幕上加载——当我在 Xcode 模拟器中测试它时它加载正常。但是,当我在我的 iPhone 4S 和 iPod Touch 5th Gen 上进行测试时,插页式广告无法加载,并且出现以下错误:
<Google> Request Error: Received invalid response.
interstitialDidFailToReceiveAdWithError:
Request Error: Received invalid response.
有没有人以前遇到过这个问题或者可能知道为什么会这样?
这是我正在使用的代码:
// interstitial ad variable...
var interstitial: GADInterstitial?
var timer:NSTimer?
var loadRequestAllowed = true
let screen = UIScreen.mainScreen().bounds
let IS_IPAD = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad
var buttonHeight:CGFloat = 0.0
var buttonOffsetY:CGFloat = 0.0
let statusbarHeight:CGFloat = 20.0
var iAdSupported = false
// load the interstitial
//Admob Interstitial
buttonHeight = IS_IPAD ? 30 : 20
buttonOffsetY = statusbarHeight
if !iAdSupported {
interstitial = createAndLoadInterstitial()
} // closes if !iAdSupported
// presentInterstitial()
timer = NSTimer.scheduledTimerWithTimeInterval(1, target:self, selector: Selector("presentInterstitial"), userInfo: nil, repeats: false)
println("the timer made presentInterstitial run")
//Interstitial func
func createAndLoadInterstitial()->GADInterstitial {
println("createAndLoadInterstitial")
var interstitial = GADInterstitial(adUnitID: "ca-app-pub-4471013071748494/2225255714")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
return interstitial
} // closes createAndLoadInterstitial …
func presentInterstitial() {
if let isReady = interstitial?.isReady {
interstitial?.presentFromRootViewController(self)
println("presentInterstitial function ran")
} // closes if let isReady
} // closes presentInterstitial …
//Interstitial delegate
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)")
// ResultsBtn?.enabled = false
interstitial = createAndLoadInterstitial()
} // closes interstitial …
最佳答案
您正试图在插页式广告有机会加载之前展示它。您的 timer
在一秒钟后触发 func presentInterstitial
。将此值更改为更大的数字以提供加载间隙时间。
import UIKit
import GoogleMobileAds
class ViewController: UIViewController, GADInterstitialDelegate {
var admobInterstitial : GADInterstitial?
var timer : NSTimer?
override func viewDidLoad() {
super.viewDidLoad()
admobInterstitial = createAndLoadInterstitial()
timer = NSTimer.scheduledTimerWithTimeInterval(5.0, target:self, selector: Selector("presentInterstitial"), userInfo: nil, repeats: false)
}
func createAndLoadInterstitial()->GADInterstitial {
var interstitial = GADInterstitial(adUnitID: "yourAdMobADUnitID")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
return interstitial
}
func presentInterstitial() {
if let isReady = admobInterstitial?.isReady {
admobInterstitial?.presentFromRootViewController(self)
}
}
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)")
admobInterstitial = createAndLoadInterstitial()
}
关于ios - 为什么我的 AdMob 插页式广告在 Xcode Simulator 中运行良好,但在我的测试设备上却不行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32549259/
如何从 tvOS 模拟器卸载应用程序? 我已经尝试长按图标,但没有出现“关闭按钮”。 我知道,这是一个 Beta 版本,也许将来他们会实现类似 iOS 的功能。 谢谢你。 最佳答案 方法一 从主屏幕:
我在IOS 8的Xcode-6 Beta中找不到新模拟器数据的目录 它不在 〜/图书馆/应用程序支持/ iPhone模拟器/ Where does the iPhone Simulator store
苹果的Whats new in Xcode 9声明我们可以录制模拟器视频。如何做到这一点? 最佳答案 使用命令行截取屏幕截图或录制视频: 在模拟器中启动您的应用。 打开终端。 要截取屏幕截图,请使用屏
我想构建一个通过 wifi 网络与其他设备通信的应用程序。因为我没有两台真正的 iOS 设备,所以我想在虚拟网络中连接两个 iOS 模拟器。起初我不知道如何/是否可以同时运行两个模拟器,其次我不知道如
我正在尝试模拟鼠标在窗口上的点击。我目前成功地执行了如下操作(我使用的是 Python,但它应该适用于一般的 win32): win32api.SetCursorPos((x,y)) win32api
我想在 ios6 和 ios7 模拟器上运行我的应用程序。我正在尝试安装 ios 6 模拟器,但收到此错误: Failed to install "iOS 6.1 Simulator" An unkn
尽管在实际设备上一切正常,但我想知道为什么从不回调代理 在 iOS 13 beta 5 上的模拟器上? 我在互联网上搜索了答案,但一无所获。 我为协议(protocol)实现了 3 个功能,如下所示:
在我的代码中,我犯了一些错误,将 NSNumber 分配给 NSString: self.totalLikesLabel.text=[user objectForKey:@"totalLikes"];
我使用的是 Xcode 6.1 和 iOS Simulator 8.1。运行我使用 iOS 模拟器编写的简单应用程序需要很长时间。构建过程没问题,但 iOS 模拟器将在应用程序启动前 5 分钟显示黑色
这个问题在这里已经有了答案: Is there a way to simulate multiple iphones using xcode/iphone sim? (10 个回答) 7年前关闭。 我
我旧安装的 Xcode 完全可以正常工作,但我尝试升级 Xcode 以使用 iOS 6,所以我在 Mac App Store 中下载了新版本,但我的 iOS 模拟器现在停止工作了,他告诉我他不能找到S
使用新的 Xcode 6,有时当我在模拟器之间切换时 - 我收到错误消息“模拟器正在使用 - 模拟器无法启动,因为它已经在使用中”。但是,模拟器未在使用中 - 我也没有在事件监视器中看到它。克服这个问
Iam running the latest OSX/Flutter/XCode Versions using flutter, android studio and firebase and
我已将 xcode 更新到 12.3,我收到了新错误。 找不到目标“arm64-apple-ios-simulator”的模块“Alamofire”;找到:x86_64-apple-ios-simul
xcode 9模拟器报错unable to boot the simulator launchd failed to respond mac os sierra 我试过从派生数据中删除内容、重新启动
更新到 Xcode 12 后,项目在模拟器上构建时给了我这个错误: Could not find module 'FrameworkName' for target 'arm64-apple-ios-
我正在尝试在 Windows PC 中使用 IOS Simulator/Emulator 或 iOS SDK 进行移动应用程序测试。是否可以在 Windows PC 中安装 IOS Simulator
我有一个关于如何在 Simpy 中调试的一般性问题。普通的调试工具似乎不起作用,因为一切都在事件循环中运行,您无法逐行检查代码并检查任何时间点存在的内容。 主要是,我感兴趣的是查找在特定时间存在哪些类
在我的模型中,我使用了一个使用自由导航的运输车。如果它是正确的,那么运输车就不能穿墙,奇怪的是在我的模型中,运输车在某一时刻以某种方式能够穿墙? 当我检查模拟时,他在红色圆圈部分的某处滑过墙。 (看截
我是编程新手,我想编写一个程序(仅供自用),每次运行时都会重复一组预设的键盘操作,谁能给我一些建议?是否有任何应用程序可以做到这一点? 最佳答案 有各种各样的程序可以满足您的需求。如果您使用的是 Wi
我是一名优秀的程序员,十分优秀!