TouchableOpacity:Why 没有触发onPress,但是触发了onLongPress?
TouchableOpacity:Why did not trigger onPress,But triggered onLongPress?
<TouchableOpacity
onPressIn={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressIn') }}
onPressOut={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressOut') }}
onPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPress') }}
onLongPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onLongPress') }}>
<Image
source={{ uri: item.images.medium }}
style={styles.item_image}
/>
</TouchableOpacity>
console.log
1574921523 "onPressIn"
1574921523 "onLongPress"
1574921523 "onPressOut"
为什么没有触发onPress,却触发了onLongPress?
https://facebook.github.io/react-native/docs/touchablewithoutfeedback#onlongpress
image: console.log
I am also facing the same issue while development, as onLongpress and
onPress both not working smoothly, but when i have made a build then
it is working as expected.
So try to make the build of the app, and it will work fine
希望这对您有所帮助....谢谢 :)
<TouchableOpacity
onPressIn={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressIn') }}
onPressOut={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPressOut') }}
onPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onPress') }}
onLongPress={() => { console.log(Math.round((new Date().getTime() / 1000)), 'onLongPress') }}>
<Image
source={{ uri: item.images.medium }}
style={styles.item_image}
/>
</TouchableOpacity>
console.log
1574921523 "onPressIn"
1574921523 "onLongPress"
1574921523 "onPressOut"
为什么没有触发onPress,却触发了onLongPress?
https://facebook.github.io/react-native/docs/touchablewithoutfeedback#onlongpress
image: console.log
I am also facing the same issue while development, as onLongpress and onPress both not working smoothly, but when i have made a build then it is working as expected.
So try to make the build of the app, and it will work fine
希望这对您有所帮助....谢谢 :)