Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何知道iOS中是否显示位置服务对话框?_Ios_Swift_Location Services - Fatal编程技术网

如何知道iOS中是否显示位置服务对话框?

如何知道iOS中是否显示位置服务对话框?,ios,swift,location-services,Ios,Swift,Location Services,据我所知,下图中的对话框仅在应用程序第一次询问位置时显示。无论用户选择什么选项(允许或不允许),此对话框都不会再次显示给用户 有没有办法知道iOS中是否已经显示位置服务提示对话框 我还想编写一些UI测试,所以我需要能够在每次运行测试时显示此对话框。我可以(通过嘲笑或其他方式)做这件事吗 (图像取自。) 检查CLAuthorizationStatus在此枚举中,您可以找到一个名为notDetermined的值,该值在用户尚未做出选择时返回 // User has not yet made a

据我所知,下图中的对话框仅在应用程序第一次询问位置时显示。无论用户选择什么选项(允许或不允许),此对话框都不会再次显示给用户

  • 有没有办法知道iOS中是否已经显示位置服务提示对话框
  • 我还想编写一些UI测试,所以我需要能够在每次运行测试时显示此对话框。我可以(通过嘲笑或其他方式)做这件事吗
(图像取自。)


检查
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
    }

谢谢有没有办法在UI测试(不是单元测试)中模拟
.authorizationStatus
始终返回
.notDetermined
状态?我不确定,但是,乍一看,我认为
.autorizationStatus
是一个只读变量,只能通过
CLLocationManager
requestAlwaysAutorization
方法或
requestInUseAutorization
method@lagoman进行更改。如果您在这方面有一些进展,请告诉我