- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们收到一份报告,其中一些用户被困在我们应用的某些屏幕中,无法继续访问应用的仪表板。
检查有问题的屏幕后,发现这是一个“正在加载”屏幕,将在用户成功登录后显示。唯一可能导致用户卡在此处的代码是 CLLocationManager。屏幕将等待 CLLocationManager 调用 didUpdateLocations 或 didFailWithError,然后进入应用程序的仪表板。
我的猜测是 CLLocationManage 没有调用它的任何委托(delegate)。因此,用户被困在“加载”屏幕中。
CLLocationManager.requestLocation 调用其委托(delegate)函数需要多长时间?如果请求时间太长,CCLocationManager 会调用 didFailWithError 吗?
以下是我们代码的缩短版本:
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
// process the location then forward to dashboard screen
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
// forward to dashboard screen
}
非常感谢任何信息! TIA!
最佳答案
如果您使用startUpdatingLocation()
,通常需要大约一秒钟才能获得第一次更新。第一次更新通常是旧的(缓存的)位置,但很快就会到达。
使用 requestLocation()
可能会花费几秒钟的时间,因为它将等待直到找到一个合适的位置。
This method returns immediately. Calling it causes the location manager to obtain a location fix (which may take several seconds) and call the delegate’s locationManager(_:didUpdateLocations:) method with the result. The location fix is obtained at the accuracy level indicated by the desiredAccuracy property. Only one location fix is reported to the delegate, after which location services are stopped.
您的问题是您没有在位置管理器上调用requestWhenInUseAuthorization()
。您必须获得使用位置的许可。除了调用该函数之外,您还需要执行一些其他操作(将键添加到应用程序的 Info.plist)。
关于swift - CLLocationManager.requestLocation 调用它的委托(delegate)需要多长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56053643/
我有一个独立的 Thread 应用程序。这是一个等待消息的监听器,当消息到达时执行一些操作,其中我必须将消息保存在数据库中。但我遇到了问题,因为如果我运行应用程序并“手动发送消息”,一切都会正常工作,
我有以下php代码: sleep(65); $query = "UPDATE database.table SET XXXXXXX = XXXXXXX - ".$YYYYYY." WHERE
我正在开发一个业余爱好应用程序。它在主布局中使用 webview。单击 webview 内的链接会使用户保持在 webview 内。启动后一切正常,但仍在应用程序内。但是,在手机休眠一段时间后,我重新
我目前运行的应用程序需要最大堆大小为 16GB。 目前我使用以下标志来处理垃圾回收。 -XX\:+UseParNewGC, -XX\:+UseConcMarkSweepGC, -XX:CMSIniti
$ uname -a Darwin Wheelie-Cyberman 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011
在 while 循环仍在休眠时退出它的最简单方法是什么?是否有某种函数可以在 sleep 时检测某个值是否为真? 或者我是否在循环中设置一个小 sleep 并检查如果不再睡一会儿就退出?如果可以,我该
我正在 Ubunu 的 Jetty 6 上运行 Java Web 服务器,用于基于反向 ajax 的 Web。而且我在向浏览器重新发送数据的线程滞后方面遇到了严重的问题。很多时候,一些线程开始 hib
当我运行长时间操作时,我遇到来自 IIS 的请求超时。我的 ASP.NET 应用程序正在后台处理数据,但处理的记录数量很大,因此操作需要很长时间。 但是,我认为 IIS 使 session 超时。这是
我不确定从哪里开始解决这个问题,但如果我有一个 AJAX 网络应用程序向服务器发送请求并在数据库(在我的例子中是 postgresql)上运行长查询,有没有办法停止或如果仍在运行时用户刷新页面或关闭
我是一名优秀的程序员,十分优秀!