react-native-amap3d ios端marker 删除未生效 BUG

336 阅读1分钟

代码跟踪

  1. AMapView.m 文件下

image.png 2. 会执行到此。container 和 originalSuperview 都是 MapView react-native 会先删除后,再加入到视图中。导致删除失效

    // Hack: At this moment we have two contradict intents.
    // First one: We want to delete the view from view hierarchy.
    // Second one: We want to animate this view, which implies the existence of this view in the hierarchy.
    // So, we have to remove this view from React's view hierarchy but postpone removing from UIKit's hierarchy.
    // Here the problem: the default implementation of `-[UIView removeReactSubview:]` also removes the view from
    // UIKit's hierarchy. So, let's temporary restore the view back after removing. To do so, we have to memorize
    // original `superview` (which can differ from `container`) and an index of removed view.

image.png

  1. 执行上面的原因是 react-native 设置删除动画时,会执行此方法

image.png

暂时性解决方案:

 LayoutAnimation.configureNext({
            delete: undefined,
          });