Swift: UICollectionView selecting cell indexPath issues

前端 未结 2 1621
-上瘾入骨i
-上瘾入骨i 2021-02-03 11:46

I am trying to do a Collection View whereby someone selects a cell and for each selection it takes them to another View Controller that ho

2条回答
  •  不知归路
    2021-02-03 11:57

    Swift 3.0

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    
        let iPath = self.collectionView.indexPathsForSelectedItems
        let indexPath : NSIndexPath = iPath![0] as NSIndexPath
        let rowIndex = indexPath.row
        print("row index = \(rowIndex)")
    }
    

提交回复
热议问题