Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何获取swift 3中收集单元格的所有索引?_Ios_Swift_Uicollectionview_Uicollectionviewcell - Fatal编程技术网

Ios 如何获取swift 3中收集单元格的所有索引?

Ios 如何获取swift 3中收集单元格的所有索引?,ios,swift,uicollectionview,uicollectionviewcell,Ios,Swift,Uicollectionview,Uicollectionviewcell,我在collectionView单元格中有一个数组。起始索引为[0,3],最后一个索引为5,3。如何获得[0,3],[5,3]之间的垂直索引。类似于swift 3中collectionView单元格中的[1,3]、[2,3]、[3,3]、[4,3] 下面是一个解决方案,它为集合视图构建所有有效索引路径的列表,然后仅过滤开始索引和结束索引之间的路径: func findIndexes(from collectionView: UICollectionView, between startIndex

我在collectionView单元格中有一个数组。起始索引为[0,3],最后一个索引为5,3。如何获得[0,3],[5,3]之间的垂直索引。类似于swift 3中collectionView单元格中的[1,3]、[2,3]、[3,3]、[4,3]

下面是一个解决方案,它为集合视图构建所有有效索引路径的列表,然后仅过滤开始索引和结束索引之间的路径:

func findIndexes(from collectionView: UICollectionView, between startIndex: IndexPath, and endIndex: IndexPath) -> [IndexPath] {

    // build the list of all possible index paths
    let allIndexPaths = (0..<collectionView.numberOfSections).flatMap { section in
        return (0..<collectionView.numberOfItems(inSection: section)).map { item in
            return IndexPath(item: item, inSection: section)
        }
    }

    // filter the ones in range
    return filteredIndexPaths = allIndexPaths.filter { indexPath in
        return startIndex < indexPath && indexPath < endIndex
    }
}
func findIndexes(来自collectionView:UICollectionView,介于startIndex:indepath和endIndex:indepath之间)->[indepath]{
//构建所有可能索引路径的列表

让allIndexPaths=(0在索引0处。我有第0节和第3行,在索引1处。我有第5节和第3行。我的问题是如何在数组中获得[“1,3”,“2,3”,“3,3”,“4,3”]索引。你能提供一些代码吗?“collectionView单元格中的数组”。那是什么?