[英]react-native-swiper wrapped in a Pressable not working properly on iOS
我正在使用 react-native-swiper 來顯示圖像,並且我想將整個 swiper 包裝在Pressable
中,並且由於其中會有多個,它們都嵌套在 FlatList 中,這就是它在代碼中的樣子:
<FlatList
data={locations}
renderItem={(props) => <Location {...props} />}
style={styles.flatList}
scrollEventThrottle={16}
refreshControl={refreshControl}
ListEmptyComponent={ListEmptyComponent}
contentInset={contentInset}
onScroll={onScroll}
contentContainerStyle={contentContainerStyle}
/>
FlatList 呈現 Location 組件,該組件返回以下內容:
<Pressable
style={{
position: "relative",
width: IMAGE_SIZE,
height: IMAGE_SIZE,
}}
onPress={() => console.log(id, " ,pressed")}
>
<Swiper
style={styles.swiper}
loop={false}
renderPagination={renderPagination}
>
{media.map((image) => (
<Image
key={image.id}
source={{ uri: image.url }}
style={{
width: IMAGE_SIZE,
height: IMAGE_SIZE,
}}
/>
))}
</Swiper>
</Pressable>
當我嘗試在圖像上滑動時,它只是不斷觸發 Pressables onPress 函數並且不想滑動到下一個圖像。 它在 Android 上按預期工作。
當我用普通的 View 組件替換 Pressable 時,一切正常。
同時,我還為組件添加了一個標題,這使事情變得有點復雜,但我設法通過使用 2 個不同的 Pressable 組件來使其工作。 不幸的是,這消除了在圖像轉換時單擊組件的能力,但它可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.