如何解决在 ScrollView ->Flat-List ->map for iPhone 6s 中使用时,可触摸组件在 ReactNative 中不起作用
当在 ScrollView -> Flat-List -> map for iPhone 6s 中使用时,所有 touchables 的 onPress 函数不会触发该函数。该代码适用于所有其他设备(iPhone X、iphone11 等)。当我使用 onPressIn 时问题得到解决,但它降低了用户体验。
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
<FlatList
data={props.seats}
keyExtractor={(index) => `seater${index}`}
scrollEnabled={false}
renderItem={({ item,index }) => (
{ props.seats[index].map(
(object,i) => (
<TouchableOpacity onPress={() => alert("Helllo")}>
</TouchableOpacity>
)
)}
)}
/>
</ScrollView>
解决方法
尝试删除 ScrollView
,因为 Flatlist
已经有滚动,对于 horizontal
,您可以像这样添加它
<FlatList
data={props.seats}
keyExtractor={(index) => `seater${index}`}
scrollEnabled={false}
renderItem={({ item,index }) => (
{ props.seats[index].map(
(object,i) => (
<TouchableOpacity onPress={() => alert("Helllo")}>
</TouchableOpacity>
)
)}
)}
horizontal // add it here
/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。