我使用Obj-C NOT SWIFT在iOS 8中使用Map Kit.我无法获得它设置的设备位置0.00,0.00,我收到错误:
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
Run Code Online (Sandbox Code Playgroud)
我实施了:(我一次只试过一次,没有运气)
if(IS_OS_8_OR_LATER) {
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestAlwaysAuthorization];
}
[self.locationManager startUpdatingLocation];
Run Code Online (Sandbox Code Playgroud)
并在info.plist中
NSLocationWhenInUseUsageDescription : App would like to use your location.
NSLocationAlwaysUsageDescription : App would like to use your location.
Run Code Online (Sandbox Code Playgroud)
我得到提示允许应用程序使用我的位置,但在我同意没有任何变化.该位置显示为0.00,0.00.
显示用户位置的代码:
//Get Location
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];
MKCoordinateRegion region = { { 0.0, 0.0 }, { 0.0, …Run Code Online (Sandbox Code Playgroud)