onPress 仅响应长按
onPress responding to a long press only
我使用 Expo 创建了一个应用程序,当 运行 在 Android 上时,onPress
需要长按才能真正响应。 TouchableOpacity
、TouchableWithoutFeedback
、react-native
的 TouchableNativeFeedback
和 react-native-elements
的 Button
都会发生这种情况。
触发 onPress
时我执行的操作类型无关紧要;我的应用程序尝试 navigate
,但即使是简单的 alert
也需要长按。下面是我使用的其中一个组件的代码,包括它的样式。 SO中的许多答案都提到了定位和zIndex,但这似乎不是我的问题。
<TouchableOpacity
style={{
width: '15%',
height: 100,
color: 'white',
borderTopWidth: 1,
borderBottomWidth: 1,
borderColor: '#333333',
alignItems: 'center',
justifyContent: 'center',
flex: 1,
flexDirection: 'column'
}}
onPress={() => this.onMenuButtonClick(item)}>
<View>
<Icon name={item.icon} color={item.colorIcon} />
<Text style={{ color: 'white' }}>{item.name}</Text>
</View>
</TouchableOpacity>
这仅在 Android 中发生,在模拟器和设备上均如此。将应用程序部署到 iOS 时工作正常。
奇怪的是,导航组件的后退箭头工作正常,只需按一下即可,但我使用的任何上述组件在按下时都不起作用。
有线索吗?
这是一个复制问题的 expo snack https://snack.expo.io/@pollirrata/cae485
移除TapGestureHandler,固定零食https://snack.expo.io/@djalik/nervous-oranges
我使用 Expo 创建了一个应用程序,当 运行 在 Android 上时,onPress
需要长按才能真正响应。 TouchableOpacity
、TouchableWithoutFeedback
、react-native
的 TouchableNativeFeedback
和 react-native-elements
的 Button
都会发生这种情况。
触发 onPress
时我执行的操作类型无关紧要;我的应用程序尝试 navigate
,但即使是简单的 alert
也需要长按。下面是我使用的其中一个组件的代码,包括它的样式。 SO中的许多答案都提到了定位和zIndex,但这似乎不是我的问题。
<TouchableOpacity
style={{
width: '15%',
height: 100,
color: 'white',
borderTopWidth: 1,
borderBottomWidth: 1,
borderColor: '#333333',
alignItems: 'center',
justifyContent: 'center',
flex: 1,
flexDirection: 'column'
}}
onPress={() => this.onMenuButtonClick(item)}>
<View>
<Icon name={item.icon} color={item.colorIcon} />
<Text style={{ color: 'white' }}>{item.name}</Text>
</View>
</TouchableOpacity>
这仅在 Android 中发生,在模拟器和设备上均如此。将应用程序部署到 iOS 时工作正常。
奇怪的是,导航组件的后退箭头工作正常,只需按一下即可,但我使用的任何上述组件在按下时都不起作用。
有线索吗?
这是一个复制问题的 expo snack https://snack.expo.io/@pollirrata/cae485
移除TapGestureHandler,固定零食https://snack.expo.io/@djalik/nervous-oranges