尝试使用 lat、lng 为 sqlite DB 绘制地图,但在地图绘制之前无法获取我的位置。哎呀!
我能做什么: 获取 100 个纬度和经度点的 sqlite DB,并将这些图钉放在地图上。看起来很棒!
我想做的是在绘制地图之前获取我的位置。但似乎:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
总是在 (void)viewDidLoad 运行后触发。无论我将其插入何处。
我需要做的是有一个启动屏幕,停在那里直到我找到一个位置,使用该纬度和经度来搜索我的 sqlite 数据库中距离我这么多英里的位置。
这是我的踪迹:
<块引用> <块引用>输入-[RootViewController initWithTabBar]
输入-[RootViewController viewDidLoad]
输入 -[RootViewController locationManager:didUpdateToLocation:fromLocation:]
这就是我真正想要的:
<块引用> <块引用>输入 -[RootViewController initWithTabBar]
输入 -[RootViewController locationManager:didUpdateToLocation:fromLocation:]
输入-[RootViewController viewDidLoad]
现在我在想(使用 tabbarcontroller),以某种方式我必须将其一直推回到我的应用程序委托?冻结整个应用程序直到我获得位置?这是我最新的想法。
感谢您提供任何提示、线索、片段......!!!我已经找了好几天了,一点运气都没有。
谢谢!!!!
What I can do:
Take a sqlite DB of 100 lat and lng points, and drop those pins on a map. Looks GREAT!
What I would like to do is get my location, BEFORE I draw my map. But it seems that:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
ALWAYS fires off AFTER (void)viewDidLoad runs. NO MATTER where I insert it.
What i need to do is have a splash screen, STOP there until I get a location, use that lat and lng to search my sqlite DB of locations within so many miles of me.
Here my trace:
Entering -[RootViewController initWithTabBar]
Entering -[RootViewController viewDidLoad]
Entering -[RootViewController locationManager:didUpdateToLocation:fromLocation:]
And here's what I really want:
Entering -[RootViewController initWithTabBar]
Entering -[RootViewController locationManager:didUpdateToLocation:fromLocation:]
Entering -[RootViewController viewDidLoad]
Now I'm thinking (working with a tabbarcontroller), do somehow I have to push this all the way back to my app delegate? Freeze the entire app until I get a location? That's my latest thoughts.
thanks for any tips, leads, snippets ... !!! I've been looking for days, no luck at all.
thanks!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您绝对不想“冻结”应用程序,并且您肯定希望在应用程序委托的
applicationDidFinishLaunching:
方法中做尽可能少的工作。我可能建议:您还可以添加两个视图,然后在正确的时间翻转它们的隐藏属性。但重点是为用户提供一些可看的东西,同时不试图对抗 Core Location 固有的异步特性。
You definitely don't want to "freeze" the app, and you definitely want to do as little work in your app delegate's
applicationDidFinishLaunching:
method as possible. What I might recommend:UIActivityIndicatorView
, or something like that.You could also add both views, and just flip their
hidden
properties at the right time. But the point is to give the user something to look at, while not trying to fight the inherently asynchronous nature of Core Location.