Bar*_*tin 5 ios uicollectionview swift
我需要我的单元格的索引UICollectionView.我知道如何得到它,但问题是当我将其转换NSIndexpath为Int.这是我的代码.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let cell = sender as! UICollectionViewCell
let index = self.collectionView!.indexPathForCell(cell)!
let vc : VideosViewController = segue.destinationViewController as! VideosViewController
vc.id_category = self.result_category[index.row as Int]["id"].intvalue
}
Run Code Online (Sandbox Code Playgroud)
您不需要转换index.row为Int,Int已经是,请参阅Apple的声明:
var row: Int { get }
Run Code Online (Sandbox Code Playgroud)
在课堂上NSIndexPath.
做吧vc.id_category = self.result_category[index.row]["id"].intvalue.请小心index of out bound数组中的内容.
我希望这对你有帮助.
| 归档时间: |
|
| 查看次数: |
3104 次 |
| 最近记录: |