简体   繁体   中英

Adding User Location Alert on MapView Loading - Xcode

I am working on Map View project but when my app loads up i get this alert on the very first screen '"Project Name Would Like to Use Your Current Location"(Alert Message) "Don't Allow"(button) "OK"(button)'(Location Alert Box) before the Map View it shows me alert on the first view i want when i switch to Map View then only the alert should come up so that at that time user can click "OK" and App will be able to use the location of user, i have searched alot but did not found some good ways to do it, i know it can be done because i have seen one or two app doing that thing but i am not able to do this feature in my app ... plz help me out in this...

I just want that the alert of location search should only show up when i reach on map view screen of my application not before that .. any suggestions ?? coding will be much appreciated.

You can simply not instantiate your CLLocationManager until you reach the screen where you want the alert to appear. It is the instantiation of the location manager that is prompting the OS to display the alert.

As GeraldWilliam already explained, its the CLLocationManager that forces the popup, which you cannot alter. However, what you could do is show the mapview and ask the user for its current location when the view is loaded, eg using the – viewDidAppear: method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM