我正在使用MKMapView在iOS模拟器中获得看起来随机发生的崩溃.它不是由任何用户操作触发的,它只是无中生有.我得到以下堆栈跟踪:
<_NSCallStackArray 0x2d9762b0>( 0 ??? 0x137d69bd 0x0 + 326986173,1 Foundation 0x03ca3b0a -[NSObject(NSkeyvalueCoding) valueForUndefinedKey:] + 282,2 Foundation 0x03c10b61 _NSGetUsingkeyvalueGetter + 81,3 Foundation 0x03c1019b -[NSObject(NSkeyvalueCoding) valueForKey:] + 260,4 AccessibilityUtilities 0x11ad1a3f -[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] + 43,5 MapKitFramework 0x12090aa4 -[MKBasicMapViewAccessibility(SafeCategory) accessibilityContainerElements] + 91,6 UIAccessibility 0x11fc7149 -[NSObject(AXPrivCategory) accessibilityElementCount] + 34,7 UIAccessibility 0x11fc751f -[NSObject(AXPrivCategory) _accessibilityHasOrderedChildren] + 59,8 UIKit 0x11ebb388 -[UIViewAccessibility(SafeCategory) _accessibilitySubviewsForGettingElementsIncludingContainers:includingOpaqueElementProviders:] + 2269,9 UIKit 0x11ebba96 -[UIViewAccessibility(SafeCategory) _accessibilityElementsInContainer:topLevel:includeKB:includeOpaqueElementProviders:] + 486,10 UIKit 0x11eba12f -[UIViewAccessibility(SafeCategory) _accessibilityElementsInContainer:topLevel:includeKB:] + 64,11 UIKit 0x11eba0ea -[UIViewAccessibility(SafeCategory) _accessibilityElementsInContainer:] + 57,12 UIKit 0x11e9b097 -[UIApplicationAccessibility(SafeCategory) _accessibilityElementFirst:last:forFocus:] + 88,13 UIKit 0x11e9b936 -[UIApplicationAccessibility(SafeCategory) _accessibilityFirstElement] + 57,14 UIKit 0x11e9ea63 -[UIApplicationAccessibility(SafeCategory) accessibilityAttributeValue:] + 333,15 UIAccessibility 0x11fbe3b9 _copyAttributeValueCallback + 151,16 AXRuntime 0x1201f431 _AXXMIGcopyAttributeValue + 139,17 AXRuntime 0x1201a300 _XcopyAttributeValue + 322,18 AXRuntime 0x120256c8 mshMIgperform + 256,19 CoreFoundation 0x0447bdd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53,20 CoreFoundation 0x0447bb0b __CFRunLoopDoSource1 + 523,21 CoreFoundation 0x044a67ec __CFRunLoopRun + 2156,22 CoreFoundation 0x044a5b33 CFRunLoopRunSpecific + 467,23 CoreFoundation 0x044a594b CFRunLoopRunInMode + 123,24 GraphicsServices 0x04f849d7 GSEventRunModal + 192,25 GraphicsServices 0x04f847fe GSEventRun + 104,26 UIKit 0x010d294b UIApplicationMain + 1225,27 Twinkie 0x000035d4 main + 228,28 libdyld.dylib 0x04a3f725 start + 0
当我检查寄存器时,我看到如下:
{ NSTargetobjectUserInfoKey = "<UIView: 0x123dd690; frame = (0 0; 320 568); autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x253f0270>; layer = <CALayer: 0x123dd6f0>>"; NSUnkNownUserInfoKey = "_annotationContainer"; }
0x123dd690是MKMapView的子视图,正如您在MKMapview上执行递归描述时所看到的:
<MKMapView: 0x123dd080; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x1d89c840>; layer = <CALayer: 0x123dd1f0>> | <UIView: 0x123dd690; frame = (0 0; 320 568); autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x253f0270>; layer = <CALayer: 0x123dd6f0>> | | <MKBasicMapView: 0x123dd720; frame = (0 0; 320 568); clipsToBounds = YES; layer = <CALayer: 0x123dd850>> | | | <_MKMapLayerHostingView: 0x123dd7a0; frame = (0 0; 320 568); layer = <_MKMapLayerHostingLayer: 0x123ddb00>> | | | | <VKMapView: 0x123ddf40> (layer) | | | | | <VKMapCanvas: 0x18826ab0> (layer) | | | | | | <VGLLayer: 0x18824510> (layer) | | <MKScrollContainerView: 0x253499e0; frame = (-407522 -982166; 2.5318e+06 2.5318e+06); autoresizesSubviews = NO; layer = <CALayer: 0x2534d0e0>> | | | <MKOverlayContainerView: 0x1d8cdef0; frame = (0 0; 2.5318e+06 2.5318e+06); transform = [0.0094316732,0.0094316732,0]; layer = <CALayer: 0x1d8cdfc0>> etc...
解决方法
我现在通过执行以下操作修复它:
#if TARGET_IPHONE_SIMULATOR @interface UIView (FixIt) @end @implementation UIView (FixIt) - (id)_annotationContainer { return nil; } @end #endif
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。