有没有办法在 ASCollectionNode 水平滚动加载更多的同时插入新项目

Is there a way to insert new items while loading more on ASCollectionNode Horizontal Scrolling

我正在使用 ASCollectionNode 水平滚动,我正在尝试向左滚动以加载更多并插入 items.but 当我到达左侧的最后一个项目时,项目已插入左侧而不是右。

我是这样实现插入的..

 func addRowsIntoPhotoCollection(newPhotoCount newPhotos: Int) {
 let indexRange = (photoFeedModel.numberOfItems - newPhotos..<photoFeedModel.numberOfItems)
    let indexPaths = indexRange.map {  IndexPath(row: [=10=], section: 0) }
    collectionView.performBatchUpdates({
        collectionView.insertItems(at: indexPaths)
    }) { (done) in
        if self.shouldScroll == true {
              self.scrollToBeginning()
        }
    }
}

要在列表末尾添加单元格,您必须创建 IndexPath 数组,其中的行比 existingRows (collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int)

  [indexPaths addObject:[NSIndexPath indexPathForRow:existingRows + i inSection:0]];

swift 版本有些像这里:

var indexPaths: [IndexPath] = []

// find number of kittens in the data source and create their indexPaths
var existingRows: Int = kittenDataSource.count + 1

for i in 0..<moarKittens.count {
    indexPaths.append(IndexPath(row: existingRows + i, section: 0))
}

// add new kittens to the data source & notify table of new indexpaths
kittenDataSource.append(contentsOf: moarKittens)
if let indexPaths = indexPaths as? [IndexPath] {
    tableNode.insertRows(at: indexPaths, with: .fade)
}