swift - 如何根据 CollectionView 中的索引路径快速删除部分?

标签 swift uicollectionview

我的功能是当我删除关闭按钮部分时,数据也会从索引路径中删除。

我已经为 Section 选择了 UICollelctionReusableView。

section count 是根据 Apple Data 数量的数组。

我附上图片

Header

数据附加到标题 像标题和一行。

我想在点击关闭按钮时删除部分和行。 谁能帮我找到解决方案?

示例代码

  var index:NSIndexPath = sender.tag
    array.removeAtIndex(indexPath.row())
    self.coll.deleteItemsAtIndexPaths([sender.tag])

最佳答案

如果你想删除整个部分,它应该是这样的:

let section = sender.tag
array.removeAtIndex(section)
collectionView.deleteSections(NSIndexSet(index: section))

鉴于所有节数据都在 array[section] 中。

关于swift - 如何根据 CollectionView 中的索引路径快速删除部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38783683/

相关文章:

ios - 同时关闭两个 NavigationController

ios - 如果当前部分单元格高度为零,则索引路径处的行的 Collectionview 单元格不会被后续部分调用

xcode - 调整 UICollectionView 高度

ios - 如何在 iOS Swift 中将 UIButton 操作从 View Controller 调用到另一个 View Controller ?

ios - 在其自身初始值内使用的变量

ios - 如何区分委托(delegate)方法中的 UITextFields?

swift - 如何在 Swift 中将从枚举接收到的值转换为字符串?

ios - CollectionViewCell 不显示 TextView

ios - 带有 CollectionViewCell 和 UILongPressGesture 错误的 XIB

ios - 在 Swift 中删除 Collection View 中的额外空间