objective-c - 使用 MKMapView 的 showUserLocation 属性

标签 objective-c gps location mkmapview

我现在有一个应用程序可以在 map 上显示各种图钉。我已经尝试设置 mapView.showsUserLocation = YES; 来显示用户的当前位置,但是这使我的应用程序崩溃(“程序收到信号:SIGABRT”)并显示以下错误消息:

Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: *** -[MKUserLocation counter]: unrecognized selector sent to instance 0x10ad60
Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[MKUserLocation counter]: unrecognized selector sent to instance 0x10ad60'
Mon Oct 19 12:31:27 unknown Hull Ads[3111] <Error>: Stack: (...)

这有点令人困惑,因为我没有使用过 MKUserLocation,或者这就是问题所在?

该应用程序确实将 CoreLocation 用于其他不相关的目的,但是当 CoreLocation 尚未被使用时,该应用程序以相同的方式响应。

如果有人能提供帮助那就太棒了!

谢谢 - 詹姆斯

最佳答案

确保在此方法中包含以下内容:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    if ([annotation class] == MKUserLocation.class) {
        return nil;
    }
    ...
}

我希望你现在已经解决了这个问题;)

关于objective-c - 使用 MKMapView 的 showUserLocation 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1588202/

相关文章:

android - 从库中的图像访问位置数据

iphone - iOS - 其他 View 中的 View

ios - 从核心数据中提取的数据不正确

iphone - 可以从主包中删除文件吗?

iphone - 在带有 objective-c 的 SQL 查询中使用 %-sign(百分号)

c# - C#中的简单移动

javascript - 访问 iPhone GPS 坐标

ios - react native : Pass target Location onPress to google maps or ios maps and execute a GPS Navigation towards said target

android - 地理围栏示例应用程序不适用于模拟位置

javascript - 使用多个链接放大位置的传单