反应原生 TouchableOpacity onPress 不适用于 Android [英] React native TouchableOpacity onPress not working on Android
本文介绍了反应原生 TouchableOpacity onPress 不适用于 Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
TouchabelOpacity 在 iOS 上运行良好,但 onPress 方法对我来说在 Android 上不起作用.
TouchabelOpacity works fine on iOS but the onPress method does not work on Android for me.
我的本机版本:0.57.4
My react-native version: 0.57.4
我的代码:
const initDrawer = navigation => (
<TouchableOpacity
style={{ left: 16 }}
onPress={() => onPressDrawerButton(navigation)}
>
<Ionicons name="ios-menu" color="white" size={30} />
</TouchableOpacity>
);
推荐答案
我遇到了类似的问题.注意从哪里导入TouchableOpacity".当我将TouchableOpacity"从react-native-gesture-handler"更改为react-native"时,它对我有用(适用于Android平台)
I had similar problem. Pay attention from where import your "TouchableOpacity". When I changed "TouchableOpacity" from "react-native-gesture-handler" to "react-native", it worked for me (for Android platform)
这篇关于反应原生 TouchableOpacity onPress 不适用于 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文