【发布时间】:2017-11-20 14:02:27
【问题描述】:
据我了解,下图中的对话框仅在应用第一次请求位置时显示。无论用户选择什么选项(允许或不允许),此对话框都不会再次显示给用户。
- 有没有办法知道定位服务提示对话框是否已在 iOS 中显示?
- 我还想编写一些 UI 测试,所以我需要能够在每次运行测试时显示此对话框。我可以以某种方式(通过模拟或其他方式)吗?
(图片取自here。)
【问题讨论】:
标签: ios swift location-services
据我了解,下图中的对话框仅在应用第一次请求位置时显示。无论用户选择什么选项(允许或不允许),此对话框都不会再次显示给用户。
(图片取自here。)
【问题讨论】:
标签: ios swift location-services
在此枚举中检查CLAuthorizationStatus,您可以找到一个名为notDetermined 的值,当用户尚未做出选择时会返回该值。
// User has not yet made a choice with regards to this application
case notDetermined
示例
if(self.locationManager.authorizationStatus == .notDetermined)
{
//Do whatever you want here
}
【讨论】:
.authorizationStatus 在 UI 测试(不是单元测试)中始终返回 .notDetermined 状态?
.autorizationStatus 是只读变量,只能通过CLLocationManager requestAlwaysAutorization 方法或requestInUseAutorization 方法@lagoman 更改如果您在这个主题上有一些进展,请告诉我