iOS LocationManager未更新位置(Titanium Appcelerator模块) [英] iOS LocationManager is not updating location (Titanium Appcelerator module)

查看:78
本文介绍了iOS LocationManager未更新位置(Titanium Appcelerator模块)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了Appcelerator Titanium模块,用于获取设备的旋转位置。可以在 GitHub 上找到源代码。

I've made Appcelerator Titanium Module for fetching device's rotaion and location. Source can be found on GitHub.

The问题是它仅获取一个缓存的位置,但是设备运动数据正常并且正在刷新。

The problem is that it fetches only one cached location but device motion data is OK and it is refreshing.

我不使用委托,而是在Titanium Javascript中提取该数据码。
如果我在模拟器->调试->位置中设置了城市运行,则什么也不会发生。返回相同的缓存位置。

I don't use delegate, I pull that data in my Titanium Javascript Code. If I set "City Run" in Simulator -> Debug -> Location nothing happens. The same cached location is returning.

可以拖拉位置,因为我尝试使用本机应用程序来做到这一点:

Pulling of location is OK because I tried with native app wich does this:

textView.text = [NSString stringWithFormat:@"%f %f\n%@",
                     locationManager.location.coordinate.longitude,
                     locationManager.location.coordinate.latitude,
                     textView.text];

它可以在模拟器和设备上运行。

And it is working in simulator and on device.

但是与您在GitHub上看到的相同的代码不能用作Titanium模块。

But the same code as you can see on GitHub is not working as Titanium module.

有什么想法吗?

编辑:

我正在查看 GeolocationModule src ,我在那没什么特别的。

I am looking at GeolocationModule src and I see nothing special there.

正如我所说,我模块中的代码必须正常工作因为它在本机应用程序中工作。 唯一的问题是它没有更新位置,它总是返回缓存的位置。

As I said, my code in my module has to work since it is working in native app. "Only" problem is that it is not updating location and it always returns me that cached location.

推荐答案

答案是ENSURE_UI_THREAD位于开始位置更新的功能的顶部。

The answer is to put ENSURE_UI_THREAD at the top of function that starts location updating.

这篇关于iOS LocationManager未更新位置(Titanium Appcelerator模块)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆