在iOS 11.0.3中插入注释视图失败

时间:2017-11-20 16:16:55

标签: ios iphone swift xcode mapkit

我几天前向App Store发布了一个应用程序,今天我去检查是否有任何崩溃。我发现在两个不同的设备上,我遇到了与 MKSpatialCollider的insertAnnotationView 相关的崩溃。两个设备都安装了iOS 11.0.3。我在ViewController中使用MapKit来显示自定义的AnnotationView对象,我也将它们分组在一起,这就是全部。我不知道这些崩溃,我的应用程序中可能发生什么触发这些事件? 下面,我附上了这两个例外情况' stacktraces,但如果您需要其他东西来弄清楚发生了什么,请告诉我:

第一个例外的堆栈跟踪

enter image description here

第二个例外的堆栈跟踪

enter image description here

更新1 - 这里是应该触发错误的代码的链接(我不确定,因为Xcode指向另一个根本不包含MapKit的文件):https://gist.github.com/MrOverflOOw/bbc14d546ef10bd17065af08fdf3e27c < / p>

5 个答案:

答案 0 :(得分:3)

对于仍在寻找类似问题答案的任何人:在我的情况下,如果用户在向MapView添加注释时按下后退按钮,我的应用会抛出上面的例外。登记/> 从这里(https://forums.developer.apple.com/thread/92799),它似乎是 iOS 11相关问题:Apple应尽快发布更新。
如果有人在此期间有进一步的信息或解决方法来解决问题,请在此处分享:我已经能够解决它 显示ActivityIndi​​cator,直到MapKit完成添加注释

答案 1 :(得分:1)

尝试从地图视图注释中删除MKClusterAnnotation的实例时遇到此错误。特别是当注释视图重用于MKClusterAnnotation时。检查你是否做了以下任何事情:

[mapView removeAnnotations:mapView.annotations];

或者如果你在Swift:

mapView.removeAnnotations(mapView.annotations)

或者您可能使用MapKit提供的MKClusterAnnotation进行任何代码行。

答案 2 :(得分:1)

对我有用的解决方法是在添加或删除任何其他注释之前取消选择注释(群集问题)。

我意识到您的案例可能不涉及添加或删除注释,但我的应用程序在相同的MKSpatialCollider代码路径中崩溃,所以我想提到这个解决方法。您可以尝试在视图消失之前取消选择注释。

答案 3 :(得分:0)

我有一个部分解决方案,虽然我尝试了上面列出的所有答案,但我仍然遇到了崩溃。

When tapping on IOS 11 MKClusterView with animation on this crash happened consistently

When tapping on IOS 11 MKClusterView with animation on this crash happened consistently

然而,当我将缩放设置为FALSE时,崩溃完全停止了!?为什么?我想放大它看起来不错:

mapView.setVisibleMapRect(zoomRect, animated: false)

这是来自这个函数(我也在其中取消选择上面建议的Cluster Annotations):

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    lastTouchedAtCoordinate = view.annotation?.coordinate
    guard let annotation = view.annotation else { return }

    if let cluster = annotation as? MKClusterAnnotation {
        var zoomRect = MKMapRectNull
        for annotation in cluster.memberAnnotations {
            self.mapView.deselectAnnotation(annotation, animated: false)
            let annotationPoint = MKMapPointForCoordinate(annotation.coordinate)

            let pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0)

            if MKMapRectIsNull(zoomRect) {
                zoomRect = pointRect
            } else {
                zoomRect = MKMapRectUnion(zoomRect, pointRect)
            }
        }
        mapView.setVisibleMapRect(zoomRect, animated: true)

    }
}

这停止了崩溃。我不知道为什么。我正在加载和添加注释很多,但我确保用户不能通过使用进度加载器来调暗背景来与地图交互(如上所述)。

我没有使用任何线程,所有UI都在主线程上完成(比如添加注释)

这是来自手机的堆栈跟踪,因为你可以看到系统正在删除注释(我完全没有,如上所述),这是一个苹果错误吗?或者我做错了什么?:

  

型号:iPhone8,1流程:
  路径:
  1.1(1.0)代码类型:ARM-64(Native)作用:Foreground Parent Process:launchd 3联盟:

     

日期/时间:2018-02-14 17:38:15.3949 +0100发布时间:
  2018-02-14 17:37:10.1854 +0100操作系统版本:iPhone OS 11.2.5   (15D60)基带版本:4.30.02报告版本:104

     

异常类型:EXC_BAD_ACCESS(SIGSEGV)异常子类型:   KERN_INVALID_ADDRESS位于0x0000000000000298 VM区域信息:0x298是   不在任何地区。以下地区之前的字节数:4328635752         区域类型开始 - 结束[VSIZE] PRT / MAX SHRMOD区域详细信息         开始时未使用的空间   ---&GT;
        __TEXT 000000010201c000-00000001022a0000 [2576K] r-x / r-x SM = COW ...... eDiveAdvisor]

     

终止信号:分段故障:11终止原因:   命名空间SIGNAL,代码0xb终止进程:exc处理程序[0]   由线程触发:0

     

已过滤的系统日志:未找到

     

线程0名称:调度队列:com.apple.main-thread线程0   崩溃:0 MapKit 0x000000019650d190    - [MKSpatialCollider insertAnnotationView:] + 244 1 MapKit 0x00000001964791b8 - [MKNewAnnotationContainerView   _updateClusterableAnnotationViews:withID:] + 456 2 MapKit 0x00000001964791b8 - [MKNewAnnotationContainerView   _updateClusterableAnnotationViews:withID:] + 456 3 CoreFoundation 0x0000000185dc51c0 - [__ NSDictionaryM   enumerateKeysAndObjectsWithOptions:usingBlock:] + 232 4 MapKit
    0x0000000196479d58 - [MKNewAnnotationContainerView   updateAnnotationViewsForReason:] + 296 5 MapKit
    0x0000000196549690 - [MKAnnotationContainerView   finishRemovingAnnotationViews] + 32 6 MapKit
    0x00000001963c56dc - [MKAnnotationManager updateVisibleAnnotations] +   1616 7 MapKit 0x00000001963c5064    - [MKAnnotationManager deselectAnnotation:animated:] + 376 8 MapKit 0x00000001963e4198 - [MKAnnotationManager   _removeAnnotation:updateVisible:removeFromContainer:] + 468 9 MapKit 0x00000001964029ac - [MKMapView removeAnnotation:] + 100 10 MapKit
    0x00000001964010b8 - [MKMapView   annotationContainer:requestRemovingClusterAnnotationView:] + 60 11   MapKit 0x0000000196479f8c   __73- [MKNewAnnotationContainerView _updateClusterableAnnotationViews:withID:] _ block_invoke + 84 12 MapKit 0x00000001964ac108   __49- [MKAnnotationView _performHideAnimationIfNeeded] _block_invoke.208 + 232 13 UIKit 0x000000018f4ea188 - [UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 764 14 UIKit 0x000000018f4e9afc - [UIViewAnimationState   sendDelegateAnimationDidStop:finished:] + 312 15 UIKit
    0x000000018f4e9808 - [UIViewAnimationState animationDidStop:finished:]   + 296 16 QuartzCore 0x0000000189f4adc4 CA :: Layer :: run_animation_callbacks + 1252804(void *)+ 284 17   libdispatch.dylib 0x0000000185876a14   _dispatch_client_callout + 16

答案 4 :(得分:0)

override func viewWillDisappear(_ animated: Bool) {  
    super.viewWillDisappear(animated)  
    mapView.removeAnnotations(mapView.annotations)  
}  

似乎为我解决了崩溃