【发布时间】:2016-09-16 12:36:38
【问题描述】:
如果用户禁用了设备位置服务,我需要在我的应用程序中找到用户的位置,我会像这样检查。
if([CLLocationManager locationServicesEnabled])
{
if([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[locationManager requestWhenInUseAuthorization];
}
}
else if(![CLLocationManager locationServicesEnabled])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Location Services are disabled please enable location services to enjoy nearby experience" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Settings", nil];
alert.tag = 103;
[alert show];
}
在我的警报视图中,我将用户引导至这样的位置设置
else if(alertView.tag == 103)
{
if(buttonIndex == 1)
{
NSURL*url=[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];
[[UIApplication sharedApplication] openURL:url];
}
}
用户从设置返回后如何再次获取位置
【问题讨论】:
标签: ios objective-c core-location cllocationmanager