addUIInterruptionMonitor(withDescription:handler :)无法在iOS 10或9上运行 [英] addUIInterruptionMonitor(withDescription:handler:) not working on iOS 10 or 9
本文介绍了addUIInterruptionMonitor(withDescription:handler :)无法在iOS 10或9上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下测试在iOS 11上运行正常。它会解除警报,询问使用位置服务的权限,然后放大地图。在iOS 10或9上,它没有这个,测试仍然成功
The following tests works fine on iOS 11. It dismisses the alert asking permissions to use the locations services and then zooms in in the map. On iOS 10 or 9, it does none of this and the test still succeeds
func testExample() {
let app = XCUIApplication()
var handled = false
var appeared = false
let token = addUIInterruptionMonitor(withDescription: "Location") { (alert) -> Bool in
appeared = true
let allow = alert.buttons["Allow"]
if allow.exists {
allow.tap()
handled = true
return true
}
return false
}
// Interruption won't happen without some kind of action.
app.tap()
removeUIInterruptionMonitor(token)
XCTAssertTrue(appeared && handled)
}
有没有人知道为什么和/或解决方法?
Does anyone have an idea why and/or a workaround?
这是你的项目可以重现这个问题: https://github.com/TitouanVanBelle/Map
Here's a project where you can reproduce the issue: https://github.com/TitouanVanBelle/Map
更新
Xcode 9.3 Beta的更新日志显示以下内容
Xcode 9.3 Beta's Changelogs show the following
XCTest UI interruption monitors now work correctly on devices and simulators running iOS 10. (33278282)
推荐答案
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let allowBtn = springboard.buttons["Allow"]
if allowBtn.exists {
allowBtn.tap()
}
这篇关于addUIInterruptionMonitor(withDescription:handler :)无法在iOS 10或9上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文