能不能 用一个 int 类型的 构造 NSIndexPath?

2015-01-31 15:22:06 +08:00
 tsinghan

我看了一下 NSIndexPath 的构造方法 应该可以
于是我尝试
videoArray.removeAtIndex(index)

var indexPath = NSIndexPath(index: index)

self.collectionView?.deleteItemsAtIndexPaths([indexPath])

但是 最后一行的时候 会报错

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (1) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted

我觉得应该是构造的不对

2672 次点击
所在节点    iOS
3 条回复
tsinghan
2015-01-31 15:40:24 +08:00
tsinghan
2015-01-31 15:51:20 +08:00
var index: NSIndexPath = NSIndexPath(forRow: 1, inSection: 1) 原来这样可以
ambitiouspei
2015-02-01 22:26:49 +08:00
@tsinghan 开始不熟多看看文档和API,可以下一个dash看着比较方便

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/167032

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX