如何根据swift中CollectionView中的索引路径删除Section?

时间:2016-08-05 07:36:34

标签: swift uicollectionview

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

我已经为Section获取了UICollelctionReusableView。

节数根据Apple数据的数量排列。

我已附上图片

Header

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

我想点击关闭按钮时删除部分和行。 任何人都可以帮我找到解决方案吗?

示例代码

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

1 个答案:

答案 0 :(得分:6)

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

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

鉴于所有部分数据都在array[section]内。

相关问题