【发布时间】:2015-01-20 18:14:41
【问题描述】:
从 ios 8 开始,我无法在调试器中启动 mapkit。我正在使用 XCode 版本 6.1 (6A1052d) 在 Mac OS X 10.9.5 上。是的,我已经阅读并搜索了一些建议,但我无法让它发挥作用。
我已在 myproject-info.plist 中添加了这些行;
</array>
<key>NSLocationUsageDescription</key>
<string>I need location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>I need location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>I need location</string>
</dict>
这就是我尝试在我的第一个视图 viewDidLoad 方法中初始化 LocationManager 的方式;
CLLocationManager *locationManager = [[CLLocationManager alloc]init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager requestAlwaysAuthorization];
[locationManager startUpdatingLocation];
稍后,在另一个控制器中,我以编程方式添加这样的 mapkit 视图;
mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
[self.view addSubview:mapView];
[mapView setDelegate:self];
mapView.showsUserLocation = YES;
但我总是在输出控制台中得到这个;
2014-11-22 19:14:36.777 vind4r[1019:16660] 尝试在不提示位置授权的情况下启动 MapKit 位置更新。必须先调用 -[CLLocationManager requestWhenInUseAuthorization] 或 -[CLLocationManager requestAlwaysAuthorization]。
有人有什么想法吗?
亲切的问候, 扬·吉瓦斯 斯德哥尔摩
【问题讨论】: