IOS 8映射不工作:尝试在不提示位置授权的情况下启动MapKit位置更新

IOS 8映射不工作:尝试在不提示位置授权的情况下启动MapKit位置更新,ios,mapkit,Ios,Mapkit,我正在使用Xcode 6。当我尝试使用CLLocationManager获取用户当前位置时,遇到了一些问题。甚至我还在Info.plist文件中添加了nslocationwhenusagedescription和NSLocationAlwaysUsageDescription。并且还使用了[CLLocationManager请求使用授权]。然后,我也得到控制台输出作为 2014-10-15 11:45:15.004 MapIOS8[1916:57908]正在尝试在不提示位置授权的情况下启动Map

我正在使用Xcode 6。当我尝试使用CLLocationManager获取用户当前位置时,遇到了一些问题。甚至我还在Info.plist文件中添加了
nslocationwhenusagedescription
NSLocationAlwaysUsageDescription
。并且还使用了
[CLLocationManager请求使用授权]
。然后,我也得到控制台输出作为

2014-10-15 11:45:15.004 MapIOS8[1916:57908]正在尝试在不提示位置授权的情况下启动MapKit位置更新。必须首先调用-[CLLocationManager RequestWhenUseAuthorization]或-[CLLocationManager requestAlwaysAuthorization]


你试过按这个顺序写代码吗

CLLocationManager *YourLocationManager = [[CLLocationManager alloc] init];
YourLocationManager.delegate = self;
[YourLocationManager requestWhenInUseAuthorization];
[YourLocationManager startUpdatingLocation];

yourMapView.delegate = self;
yourMapView.showsUserLocation = YES;
此外,要获取用户位置坐标,可能必须实现此mapkit委托方法

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    NSLog(@"%f, %f", userLocation.coordinate.latitude, userLocation.coordinate.longitude);

    [mapView selectAnnotation:userLocation animated:YES];
}

如果您使用的是iOS模拟器,请尝试从设置->常规->隐私->重置位置和隐私中重置位置设置。然后打电话:

[LocationManager requestAlwaysAuthorization];
在第一次执行时,必须出现一个弹出窗口,以允许使用当前用户的位置。允许使用当前位置后,使用以下命令启动LocationManager:

[LocationManager startUpdatingLocation];

所以,您只需要获取用户的当前位置?很明显,您正在调用requestWhenInUse to late。。。显示您的代码。我想要的是,我想要在地图上显示用户的当前位置-(void)viewDidLoad{[super viewDidLoad];CLLocationManager*myManager=[[CLLocationManager alloc]init];myManager.delegate=self;if([CLLocationManager respondsToSelector:@selector(requestwhenUseAuthorization)]{NSLog(@“在此方法内部”);[myManager requestWhenInUseAuthorization];}MKCoordinateRegion myregion;myregion.span.latitudeDelta=0.11;myregion.span.longitudeDelta=0.11;[myMap setRegion:myregion animated:YES];}您不应该启用“显示当前位置”“属性,直到您对CLLocationManagerDelegate委托进行了成功的授权回调