Javascript 为什么应用程序在MapView.Marker被拖动后崩溃?
我有Javascript 为什么应用程序在MapView.Marker被拖动后崩溃?,javascript,ios,react-native,android-mapview,marker,Javascript,Ios,React Native,Android Mapview,Marker,我有react native中带有MapView的组件-maps@0.12.2在我的应用程序中。在MapView中,我有一个可拖动的MapView.Marker。 问题是,有时当我拖动这个标记时,这个应用程序会意外崩溃。是的,有时候,这就是奇怪的地方 Terminating app due to uncaught exception 'NSRangeException', reason:'Cannot remove an observer <AIRMapManager 0x60800000
react native中带有MapView
的组件-maps@0.12.2
在我的应用程序中。在MapView中,我有一个可拖动的MapView.Marker
。
问题是,有时当我拖动这个标记时,这个应用程序会意外崩溃。是的,有时候,这就是奇怪的地方
Terminating app due to uncaught exception 'NSRangeException', reason:'Cannot remove an observer <AIRMapManager 0x6080000096b0> for the key path "center" from <AIRMapMarker 0x7fdb4a68f4f0> because it is not registered as an observer.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c9e0b2b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010b89b281 objc_exception_throw + 48
2 CoreFoundation 0x000000010ca49685 +[NSException raise:format:] + 197
3 Foundation 0x000000010b3b8a38 -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 497
4 Foundation 0x000000010b3b87ec -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 84
5 mojazastavka_ios 0x000000010aed6949 -[AIRMapManager mapView:annotationView:didChangeDragState:fromOldState:] + 1321
6 MapKit 0x000000010e66dd9a -[MKMapView _annotationViewDragStateChanged:] + 440
7 CoreFoundation 0x000000010c97fc2c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x000000010c97fb29 _CFXRegistrationPost + 425
9 CoreFoundation 0x000000010c97f892 ___CFXNotificationPost_block_invoke + 50
10 CoreFoundation 0x000000010c943132 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
11 CoreFoundation 0x000000010c942291 _CFXNotificationPost + 673
12 Foundation 0x000000010b367328 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
13 MapKit 0x000000010e73f916 -[MKAnnotationView setDragState:animated:] + 224
14 MapKit 0x000000010e7ebb4f -[MKAnnotationContainerView _dropDraggingAnnotationViewAnimated:] + 276
15 MapKit 0x000000010e66b928 -[MKMapView _dropDraggingAnnotationView:] + 91
16 MapKit 0x000000010e66bbac -[MKMapView handleLongPress:] + 604
17 UIKit 0x000000010f553751 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
18 UIKit 0x000000010f55b54f _UIGestureRecognizerSendTargetActions + 109
19 UIKit 0x000000010f558f03 _UIGestureRecognizerSendActions + 225
20 UIKit 0x000000010f5581c6 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 981
21 UIKit 0x000000010f544728 _UIGestureEnvironmentUpdate + 1219
22 UIKit 0x000000010f544219 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
23 UIKit 0x000000010f5433e0 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
24 UIKit 0x000000010f092baa -[UIWindow sendEvent:] + 4092
25 UIKit 0x000000010f03f274 -[UIApplication sendEvent:] + 352
26 UIKit 0x000000010f81efa8 __dispatchPreprocessedEventFromEventQueue + 2932
27 UIKit 0x000000010f816f74 __handleEventQueue + 1115
28 CoreFoundation 0x000000010c986c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x000000010c96c0af __CFRunLoopDoSources0 + 527
30 CoreFoundation 0x000000010c96b5df __CFRunLoopRun + 911
31 CoreFoundation 0x000000010c96aff6 CFRunLoopRunSpecific + 406
32 GraphicsServices 0x0000000112905979 GSEventRunModal + 62
33 UIKit 0x000000010f021bb1 UIApplicationMain + 159
34 mojazastavka_ios 0x000000010aecd67f main + 111
35 libdyld.dylib 0x00000001109fc66d start + 1
36 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
由于未捕获的异常“NSRangeException”而终止应用程序,原因:“无法从中删除密钥路径“center”的观察者,因为它未注册为观察者。”
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x000000010c9e0b2b例外预处理+171
1 libobjc.A.dylib 0x000000010b89b281 objc_异常_抛出+48
2 CoreFoundation 0x000000010ca49685+[N异常提升:格式:][197
3基金会0x000 000 010B3B8A38 - [NSObjist](NKEY ValueObServer注册)
4基金会0x000 000 010B3B8EC-[NSbObjs](NSKEY ValueBoServer注册)Relphi观察员:FoKePix::+ 84
5 mojazastavka_ios 0x000000010aed6949-[AIRMapManager地图视图:注释视图:didChangeDragState:fromOldState:+1321
6地图套件0x000000010e66dd9a-[MKMapView\u注释视图DragStateChanged:+440
7 CoreFoundation 0x000000010c97fc2c通知中心正在召集观察员
8 CoreFoundation 0x000000010c97fb29_CFXRegistrationPost+425
9 CoreFoundation 0x000000010c97f892\uuuuuuuuuuuuuuuuuuxNotificationPost\u block\u invoke+50
10 CoreFoundation 0x000000010c943132-[\u cfxNotificationRegistrator查找:对象:观察者:枚举器:][1826
11核心基金会0x000000010c942291\u CFXNotificationPost+673
12基金会0x000 000 010B367328 - [ NSnPosiCICTeCsPoestPosiTrimeTrimeNo:对象:用户信息:] + 66
13地图套件0x000000010e73f916-[MKAnnotationView setDragState:动画:][224
14地图套件0x000000010e7ebb4f-[MKAnnotationContainerView\u DropDragingAnnotationViewAnimated:+276
15地图套件0x000000010e66b928-[MKMapView\u DropDragingAnnotationView:+91
16地图套件0x000000010e66bbac-[MKMapView handleLongPress:][604
17 UIKit 0x000000010f553751-[UIgestureRecognitizerTarget\u SendActionWithgestureRecognitizer:+57
18 UIKit 0x000000010F554F _UIgestureRecognitizerSendTargetActions+109
19 UIKit 0x000000010f558f03 _UIgestureRecognitizerSendActions+225
20 UIKit 0x000000010f5581c6-[UIgestureRecognitor\u updategestruewevent:buttonEvent:+981
21 UIKit 0x000000010f544728\u UIgestureEnvironment更新+1219
22 UIKit 0x000000010f544219-[UIGestureEnvironment\u deliverEvent:TogestureRecognitors:usingBlock:+484
23 UIKit 0x000000010f5433e0-[UIGestureEnvironment\u UpdategSturesForEvent:window:+274
24 UIKit 0x000000010f092baa-[UIWindow sendEvent:+4092
25 UIKit 0x000000010f03f274-[UIApplication sendEvent:+352
26 UIKit 0x000000010f81efa8 uuu调度预处理事件RomeventQueue+2932
27 UIKit 0x000000010f816f74 u_-handleEventQueue+1115
28 CoreFoundation 0x000000010c986c01\uuuu CFRUNLOOP\u正在调用\uu OUT\u以执行\uu功能\uuuu+17
29 CoreFoundation 0x000000010c96c0af\uuu CFRunLoopDoSources0+527
30 CoreFoundation 0x000000010c96b5df\uuuu CFRunLoopRun+911
31 CoreFoundation 0x000000010c96aff6 CFRunLoopRunSpecific+406
32图形服务0x0000000112905979 GSEventRunModal+62
33 UIKit 0x000000010f021bb1 UIApplicationMain+159
34 mojazastavka_ios 0x000000010aecd67f干管+111
35 libdyld.dylib 0x00000001109fc66d启动+1
36°?0x0000000000000001 0x0+1
)
libc++abi.dylib:以NSException类型的未捕获异常终止
我真的不知道是什么原因导致了这种情况,代码是根据官方示例编写的:
import React, {Component} from 'react';
import MapView from 'react-native-maps';
import MyCustomCallout from './MyCustomCallout';
export default class Map extends Component{
constructor(props) {
super(props);
let marker = null;
}
render(){
return (
<MapView>
<MapView.Marker
draggable
onDragEnd={e => console.log(e.nativeEvent)}
coordinate={{
latitude: this.props.latitude,
longitude: this.props.longitude
}}
ref={ref => this.marker = ref }
image={finishImg}>
<MyCustomCallout type={'FINISH'} descriptionText={this.props.destinationName} />
</MapView.Marker>
</MapView>
);
}
}
import React,{Component}来自'React';
从“react native maps”导入MapView;
从“/MyCustomCallout”导入MyCustomCallout;
导出默认类映射扩展组件{
建造师(道具){
超级(道具);
设marker=null;
}
render(){
返回(
console.log(e.nativeEvent)}
协调={{
纬度:这个。道具。纬度,
经度:这个。道具。经度
}}
ref={ref=>this.marker=ref}
image={finishImg}>
);
}
}
通过从模拟器中删除应用程序并重建项目解决了问题。原液