UICollectionView 连续插入分区刷新问题

2021-03-05 11:01:10 浏览数 (1)

11Pro 以下手机

代码语言:javascript复制
                if self.arrDataSource.count > 1 {
                    var insertIndexPathMap = [IndexPath]()
                    let section = self.arrDataSource.count - 1
                    for index in 0..<similarModelList.count {
                        let indexPa = IndexPath(item: index, section: section)
                        insertIndexPathMap.append(indexPa)
                    }
                    self.collectionView.performBatchUpdates({
                        self.collectionView.insertSections(IndexSet(integer: section))
                        self.collectionView.insertItems(at: insertIndexPathMap)
                    }) { (finish) in
                        if finish {
                            print("90900900")
                        }
                    }
                } else {
                    self.collectionView.reloadData()
                }

11Pro 以上手机必须加入 真他妈的坑

代码语言:javascript复制
                    self.collectionView.layoutIfNeeded()
代码语言:javascript复制
                if self.arrDataSource.count > 1 {
                    var insertIndexPathMap = [IndexPath]()
                    let section = self.arrDataSource.count - 1
                    for index in 0..<similarModelList.count {
                        let indexPa = IndexPath(item: index, section: section)
                        insertIndexPathMap.append(indexPa)
                    }
                    self.collectionView.performBatchUpdates({
                        self.collectionView.insertSections(IndexSet(integer: section))
                        self.collectionView.insertItems(at: insertIndexPathMap)
                    }) { (finish) in
                        if finish {
                            print("90900900")
                        }
                    }
                } else {
                    self.collectionView.reloadData()
                    self.collectionView.layoutIfNeeded()
                }

0 人点赞