【发布时间】:2019-11-22 19:09:44
【问题描述】:
我一直在尝试在 react-native-maps Marker 中使用 TouchableOpacity 代码:
<MapView.Marker
coordinate={{
latitude: marker.lat,
longitude: marker.lng
}}
anchor={{ x: 0, y: 0 }}
centerOffset={{ x: 0, y: 0 }}
calloutOffset={{ x: 0, y: 0}}
title={marker.title}
description="Sample Description"
>
<TouchableOpacity
onLongPress={() => {console.log("MARKER LONG PRESSED")}}
delayLongPress={1000}
onPress={()=>{console.log("MARKER PRESSED")}}
>
// here i have a custom image for the marker
</TouchableOpacity>
</MapView.Marker>
现在的问题是这在 ios 上运行良好,onPress 和 onLongPress 事件都被调用,但在 android 上它们都没有被调用,这太令人困惑了,我不知道为什么。这里有什么我遗漏的或者我应该添加的东西吗?
而且我正在从react-native-gesture-handler 导入ToucahbleOpacity。我尝试从react-native 导入它,但这在两个平台上都不起作用
【问题讨论】:
标签: android react-native react-native-maps long-press touchableopacity