【问题标题】:MKMapView not Rendering in iOS 8 or laterMKMapView 在 iOS 8 或更高版本中不呈现
【发布时间】: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 和上面的代码行中添加这两个值,我可以在地图上显示用户位置的用户位置和注释,但地图是空白的。

与这篇文章类似: MKMapView showing blank screen in iOS 8

【问题讨论】:

    标签: ios8 mkmapview


    【解决方案1】:

    在 IOS8.3 上的 sim 卡和设备都具有相同的功能。 通过运行系统地图应用程序(它也显示空网格)一分钟直到它下载地图来解决。之后我的 MKMapView 开始正常渲染。

    【讨论】:

    • 我们有同样的问题,这个“补丁”也对我们有用。 IMO,要求用户打开地图应用程序并返回您的应用程序是没有意义的。有什么方法可以“强制”地图刷新和/或地图下载?谢谢。
    • 这个问题发生在我身上,因为地图应用程序从未在测试设备上打开过。打开后我需要接受协议,现在我自己的地图每次都能完美加载。
    • 它帮助了我。谢谢。
    • 谢谢。为我工作。 ?
    【解决方案2】:

    尝试添加委托方法:
    - (void)mapViewWillStartLoadingMap:(MKMapView *)mapView; - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView; - (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error; 并检查您的错误消息的解决方案。

    还检查this 解决方案,我没有摆脱困境,但至少我摆脱了 didFail 错误。

    但似乎是 iOS8 的问题,因为在 iOS8.3 上可以正常工作相同的代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 2023-03-31
      • 2020-02-09
      相关资源
      最近更新 更多