ios - React Native FlatList 消耗所有触摸(ToucableWithoutFeedback onPress 未调用)

标签 ios react-native touch react-native-flatlist

我的 React Native 应用程序中有一个 FlatList,我正在渲染常规单元格。我像往常一样在单元格内添加了 TouchableonPress 事件,但我的单元格没有接收触摸事件。我目前在 iOS 上,我尝试拦截触摸事件(通过覆盖 Xcide 中的 UIApplications touchesBegan:withEvent: 方法),但由于某种原因,应用程序无法拦截触摸事件。在 FlatList 内点击时接收触摸事件(未调用该方法)。平面列表滚动良好(手势识别器工作),但不知何故应用程序(并且没有 View )没有接收触摸事件。如果我点击 FlatList 边界之外的任何位置,触摸就会被正确接收和处理。

如何让触摸事件正常工作?我使用的是 React Native 0.59.8。

最佳答案

这是 React Native 的一个错误(尽管该错误由于不活动而被关闭,但这正是我身上发生的事情),地址为 https://github.com/facebook/react-native/issues/23740 。我已切换到 TouchableOpacity,并将不透明度设置为 1(以模仿相同的视觉行为),问题就消失了。尽管这不是一个真正的解决方案,而是一个解决方案,但该错误源自 React Native 本身,因此我认为使用该解决方案是目前最好的解决方案。

关于ios - React Native FlatList 消耗所有触摸(ToucableWithoutFeedback onPress 未调用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56281665/

相关文章:

android - java.lang.ClassNotFoundException : Didn't find class "com.my_app_name.androidx"

iOS ViewController 层次结构随 Unity 4.6.5 和 Vuforia 4.2 更新而改变

ios - 字典作为函数返回类型

react-native-dropdown-picker 无法从 renderlistitem 中选择项目

react-native - 如何在 React Native 中等待 Alert 对话框的响应?

ios - GSSendEvent - 注入(inject)触摸事件 iOS

ios - GoogleToolboxForMac 和 GoogleOpenSource.framework 之间的冲突,因为两者都包含 GTMLogger 文件

objective-c - 动画在 iOS6 中工作,在 iOS5 中有错误

JQuery、Kinetic.js 和 MSPointer 事件(如何 addEventListener,或者 on() 会起作用吗?)

iphone - 移动Safari : Disable scrolling pages "out of screen"