【发布时间】:2015-02-16 22:19:51
【问题描述】:
我在 iOS 8.x.x 的 MKMapView 中遇到问题。应用程序在 iOS 7.x.x 中运行良好,但在 iOS 8.x.x 中无法正常运行。在设备上,它只显示注释,但后面没有地图。
我也尝试强制重置我的设备,但没有成功。
我在 info.plist 中添加了这两个值,这是 iOS 8 及更高版本的要求
<key>NSLocationAlwaysUsageDescription</key>
<string>Location is required to find out where you are</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location is required to find out where you are</string>
并在我的 Viewdidload 中添加了这行代码。
// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
//[self.locationManager requestAlwaysAuthorization];
self.myMapView.showsUserLocation = YES;
}
通过在 info.plist 和上面的代码行中添加这两个值,我可以在地图上显示用户位置的用户位置和注释,但地图是空白的。
【问题讨论】: