由网友(枕下悲绪)分享简介:我需要我的应用程序来访问用户的当前位置.它在应用程序的开头检查用户是否设置了它.如果不是,我需要该应用程序显示提示以使其使用位置服务.就像警报视图一样,点击按钮后,它会带您进入 iphone 上的定位服务屏幕.I need my app to access the user's current location. I...
我需要我的应用程序来访问用户的当前位置.它在应用程序的开头检查用户是否设置了它.如果不是,我需要该应用程序显示提示以使其使用位置服务.就像警报视图一样,点击按钮后,它会带您进入 iphone 上的定位服务屏幕.
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.
推荐答案
您可以通过此代码检查 locationServicesEnabled 以及您的应用程序是否允许定位服务:
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
}
相关推荐
最新文章