Trying to plot a map using lat, lng for a sqlite DB, but CANT get my location before the map draws. UGGG!
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]
开发者_JS百科
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!!!!
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:
- Have two views: one is the "real" view with the map, (presumably) controlled by some view controller. The other is just a simple "waiting" view with a message to the user and a
UIActivityIndicatorView
, or something like that. - When your app launches, load and display the waiting view in your app's window, and kick off the location manager to find the user's current location.
- When you've got enough location information, load the real view, add it to the window, and remove the waiting view. (Maybe with a nice cross-fade animation or something.)
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.
精彩评论