OGeek|极客世界-中国程序员成长平台

标题: ios - 为什么 Flatlist 中的图像有时无法渲染? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:41
标题: ios - 为什么 Flatlist 中的图像有时无法渲染?

我正在尝试修复我的平面图像列表,有时当我加载屏幕时会加载所有图像,有时会加载随机数量的图像,我不知道为什么。关于如何让所有图像始终一致地呈现的任何建议?

图片来源来自外部网址。

我已经为这个问题添加了一个 gif。它向我展示了切换屏幕,以及每次我返回到 Flatlist 图像网格时得到的不同结果。

https://imgur.com/HmC3Dvr

我已经尝试过 flatlist Prop removeClippedSubviews={true} 和 {false}。

renderItem = ({ item, index }) => {
  return(
    //console.log(item)
    <TouchableHighlight onPress={this.props.toggleView.bind(this, index)} > 
      <View >
      <Image source={{uri: item.images.thumbnail.url, cache:'force-cache'}} style={styles.item} resizeMode={"resize"}/>      
      </View>
      </TouchableHighlight>
   ) 
 }


render(){
return(
        <FlatList
        ref={(ref) => { this._flatList = ref; }}
        data={this.props.profileMedia}
        onScroll={this.handleScroll}
        renderItem={this.renderItem.bind(this)}
        numColumns={3}
        ListHeaderComponent={this.renderHeader}
        ListFooterComponent={this.renderFooter}
        columnWrapperStyle={{justifyContent: 'flex-start'}}
        contentOffset = {{x: 0, y:this.props.scrollPosition}}
        keyExtractor={item => item.id}
        initialNumToRender={12}
      />
  )
 }



Best Answer-推荐答案


尝试检查图像的分辨率,React Native 通常会遇到大分辨率图像的垃圾收集问题。

关于ios - 为什么 Flatlist 中的图像有时无法渲染?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55579557/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4