【发布时间】:2016-03-28 15:13:25
【问题描述】:
我有一个 UICollectionView,我想始终将数据(图像)保存在第一个单元格中,而旧数据会转到下一个单元格。所以当我保存一张新照片时,它出现在第一个单元格中,我尝试在 cellForRowAtIndexPath 中使用 indexpath.row == 0 {} 但他只保存在其他单元格中的第一个单元格中什么都没有。我可以反转保存索引还是换一种方式?
那么有人知道我可以在那里做什么吗??
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return picture.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("BookPicCell", forIndexPath: indexPath) as! BookPicCell
let cellcore = picture[indexPath.row]
if indexPath.row == 0 {
cell.BookImage.image = UIImage(contentsOfFile: cellcore.foto!)
}
return cell
}
感谢您的帮助。
【问题讨论】:
标签: swift uicollectionview uicollectionviewcell nsindexpath