问题
I need my app to access the user's current location. It checks at the beginning of the app if the user has it set or not. and if not i need the app to show a prompt for it to use location services. Like a an alert view and on lick of the button it should take you to the screen of location services on iphone.
回答1:
You can check the for locationServicesEnabled and if the location service is allowed for your application by this code:
if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) {
//do your works
} else {
//show an alert
}
来源:https://stackoverflow.com/questions/25018784/how-to-request-the-user-to-turn-on-location-services