我试图在我的应用程序中获取 iphone 的位置数据,但由于某种原因,我一直kclAuthorizationStatusNotDetermined
在我的switch
块中。
我知道在模拟器上启用了位置服务,并且我CLLocationManager
在我的头文件中声明了一个事实,所以我知道它存在。
我的代码如下:
if ([CLLocationManager locationServicesEnabled])
{
//check if this app is allowed to access geolocation
switch ([CLLocationManager authorizationStatus])
{
case kCLAuthorizationStatusNotDetermined:
// do something
NSLog(@"Status not determined");
break;
case kCLAuthorizationStatusDenied:
//do something
NSLog(@"Status denied");
break;
case kCLAuthorizationStatusRestricted:
//do something
NSLog(@"Status restricted");
break;
case kCLAuthorizationStatusAuthorized:
[manager startUpdatingLocation];
CLLocation *currentCoords = [manager location];
NSString *location = [currentCoords description];
UIAlertView *gps = [[UIAlertView alloc]
initWithTitle:@"Current Location" message:location delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[gps show];
//getHails or getDetails();
break;
}
}
我错过了什么吗?提前感谢您的帮助