Ant*_*ton 1 cell ios uicollectionview uicollectionviewcell swift
我有一个问题是在我的集合视图中添加额外的单元格我已经更改了逻辑以使用数据模型来填充我的单元格
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return pictures.count + 1
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("images", forIndexPath: indexPath) as! ProfileImageCell
let picture = pictures[indexPath.item] as! Gallery
print(indexPath.item)
if indexPath.item == pictures.count {
cell.image.image = UIImage(named: "ProfilePlusImage")
} else {
cell.image.sd_setImageWithURL(NSURL(string: picture.fileUrl), placeholderImage: UIImage(named: "Placeholder"))
cell.imageId = picture.id.integerValue
}
return cell
}
Run Code Online (Sandbox Code Playgroud)
我想这个问题就在这一行
让picture = pictures [indexPath.item]为!画廊
当我标记并标记时
cell.image.sd_setImageWithURL(NSURL(string:picture.fileUrl),placeholderImage:UIImage(named:"placeholder"))
它在第11位增加了额外的细胞.但是其他方式让我超越了界限
谁能帮助我?
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("images", forIndexPath: indexPath) as! ProfileImageCell
print(indexPath.item)
if indexPath.item == pictures.count {
cell.image.image = UIImage(named: "ProfilePlusImage")
} else {
let picture = pictures[indexPath.item] as! Gallery
cell.image.sd_setImageWithURL(NSURL(string: picture.fileUrl), placeholderImage: UIImage(named: "Placeholder"))
cell.imageId = picture.id.integerValue
}
return cell
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1483 次 |
| 最近记录: |