fs_*_*gre 5 ios uicollectionview swift
从 中删除单元格的最常见方法是什么UICollectionView
?
在UITableView
我使用editActionsForRowAt
或editingStyle
方法删除行中,是否UIControllerView
有类似的东西或者您需要实现自己的删除方法?
我拥有的是UICollectionView
很多照片,其中每个单元格/照片都附加到一个segue,这会将您带到照片的更大版本。
最简单的方法是在方法中执行此操作didSelectItemAt
,但在我的情况下,这不是一个选项,因为一旦点击照片,它就会转到另一个 viewController (较大的图像)。
在我上面描述的情况下添加删除功能的最佳方法是什么?
以下主题展示了如何使用didSelectItemAt
.
如何在 Swift 中向 Collection View Cell 添加删除按钮?
如何从集合视图中删除项目?
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return fruits.count
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "fruitCustomCell", for: indexPath) as! fruitCollectionViewCell
cell.labelFruitName.text = fruits[indexPath.row].fruitName
return cell
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1686 次 |
最近记录: |