问题描述
我在用户界面中有一个按钮,可以反转地理位置(拉街名基地在拉特和长)。唯一的问题是由
CLLocation * location = [[self locationManager] location]检索到的位置对象;如果用户点击太快,
为零。我正在初始化viewDidLoad中的LocationManager,因为除非用户实际加载此屏幕,否则我不想创建对象。我开始马上更新位置......但如果用户加载屏幕并立即点击GPS按钮,则位置为零。
这里是问题:你知道CLLocationManager需要多长时间检索位置吗?
谢谢
检索这些数据。为了便于使用,您可能需要停用按钮控件。找到位置后,触发 NSNotification
。注册您的视图控制器以侦听此通知,该通知会触发重新激活按钮控件的选择器。
I have written an iPhone app that uses the iPhone's relative GPS location.
I have a button in the user interface that does reverse geolocation (pulls the street name bases on the lat and long). The only problem is that the location object as retrieved by
CLLocation *location = [[self locationManager] location];
is nil if the user taps the button too soon. I am initializing the LocationManager in viewDidLoad as I don't want to object to be created unless the user actually loads this screen. I start updating the location straight away as well... but still if the user loads the screen and taps the GPS button straight away the location is nil.
Here comes the question: do you know roughly how much time the CLLocationManager needs to retrieve the location?
Thanks
It can take the phone a few seconds to retrieve this data. For usability, you may want to deactivate the button control. Fire an NSNotification
once the location is found. Register your view controller to listen for this notification, which fires a selector that re-activates the button control.
这篇关于GPS位置需要几秒钟才能恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!