我使用一个界面使用BMKMapView, 第一次和第二次进去那个界面没问题, 第三次进去百分百出现这个问题
* thread #1: tid = 0x382c35, 0x000000010e523d70 AppointmentsRide`-[BMMapViewManager getCMapControlWithMapView:] + 515, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x000000010e523d70 AppointmentsRide`-[BMMapViewManager getCMapControlWithMapView:] + 515
frame #1: 0x000000010e5ddc5a AppointmentsRide`-[MapController initMapControl:] + 76
frame #2: 0x000000010e5e1238 AppointmentsRide`-[MapView initWithFrame:] + 385
frame #3: 0x000000010e4f03eb AppointmentsRide`-[BMKMapView initMapView] + 227
frame #4: 0x000000010e4ef5b6 AppointmentsRide`-[BMKMapView initSubView] + 541
frame #5: 0x000000010e4f12f4 AppointmentsRide`-[BMKMapView initWithCoder:] + 142
frame #6: 0x0000000110f6728b UIKit`-[UIClassSwapper initWithCoder:] + 205
frame #7: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #8: 0x00000001110b8c85 UIKit`UINibDecoderDecodeObjectForValue + 1168
frame #9: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #10: 0x0000000110cf2050 UIKit`-[UIView initWithCoder:] + 850
frame #11: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #12: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #13: 0x000000010f1c2803 Foundation`-[NSLayoutConstraint initWithCoder:] + 465
frame #14: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #15: 0x00000001110b8c85 UIKit`UINibDecoderDecodeObjectForValue + 1168
frame #16: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #17: 0x000000011130ecf3 UIKit`-[_UILayoutGuide initWithCoder:] + 168
frame #18: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #19: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #20: 0x000000010f1c2726 Foundation`-[NSLayoutConstraint initWithCoder:] + 244
frame #21: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #22: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #23: 0x0000000110f66e84 UIKit`-[UIRuntimeConnection initWithCoder:] + 153
frame #24: 0x00000001110b8ab6 UIKit`UINibDecoderDecodeObjectForValue + 705
frame #25: 0x00000001110b8c85 UIKit`UINibDecoderDecodeObjectForValue + 1168
frame #26: 0x00000001110b87ec UIKit`-[UINibDecoder decodeObjectForKey:] + 276
frame #27: 0x0000000110f66327 UIKit`-[UINib instantiateWithOwner:options:] + 990
frame #28: 0x0000000110dbe718 UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 242
frame #29: 0x0000000110dbed08 UIKit`-[UIViewController loadView] + 109
frame #30: 0x0000000110dbef79 UIKit`-[UIViewController loadViewIfRequired] + 75
frame #31: 0x0000000110dbf40e UIKit`-[UIViewController view] + 27
frame #32: 0x0000000110de4297 UIKit`-[UINavigationController _startCustomTransition:] + 633
frame #33: 0x0000000110df03bf UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 386
frame #34: 0x0000000110df0f0e UIKit`-[UINavigationController __viewWillLayoutSubviews] + 43
frame #35: 0x0000000110f3b715 UIKit`-[UILayoutContainerView layoutSubviews] + 202
frame #36: 0x0000000110d0ea2b UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
frame #37: 0x000000010ef9dec2 QuartzCore`-[CALayer layoutSublayers] + 146
frame #38: 0x000000010ef926d6 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 380
frame #39: 0x000000010ef92546 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
frame #40: 0x000000010eefe886 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 242
frame #41: 0x000000010eeffa3a QuartzCore`CA::Transaction::commit() + 462
frame #42: 0x000000010ef000eb QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 89
frame #43: 0x00000001100a2ca7 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
frame #44: 0x00000001100a2c00 CoreFoundation`__CFRunLoopDoObservers + 368
frame #45: 0x0000000110098a33 CoreFoundation`__CFRunLoopRun + 1123
frame #46: 0x0000000110098366 CoreFoundation`CFRunLoopRunSpecific + 470
frame #47: 0x0000000114ff9a3e GraphicsServices`GSEventRunModal + 161
frame #48: 0x0000000110c8e900 UIKit`UIApplicationMain + 1282
* frame #49: 0x000000010e3faebf AppointmentsRide`main(argc=1, argv=0x00007fff518752e0) + 111 at main.m:14
frame #50: 0x00000001120aa145 libdyld.dylib`start + 1
原因:
//动态更新我的位置数据
[_mapView updateLocationData:userLocation];
我更新地图,定位到我的当前位置,调用这个方法。 因为我是放在代码块里面,这样子调用有问题,会出现线程崩溃。使用[self.mapView updateLocationData:userLocation];也会出现这个问题
解决方法: 使用weakSelf, 不能使用self或者_mapView
[weakSelf.mapView updateLocationData:userLocation];