V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
tsinghan
V2EX  ›  iOS

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

  •  
  •   tsinghan · 2015-01-31 15:22:06 +08:00 · 2658 次点击
    这是一个创建于 3374 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我看了一下 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

    我觉得应该是构造的不对

    3 条回复    2015-02-01 22:26:49 +08:00
    tsinghan
        2
    tsinghan  
    OP
       2015-01-31 15:51:20 +08:00
    var index: NSIndexPath = NSIndexPath(forRow: 1, inSection: 1) 原来这样可以
    ambitiouspei
        3
    ambitiouspei  
       2015-02-01 22:26:49 +08:00
    @tsinghan 开始不熟多看看文档和API,可以下一个dash看着比较方便
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2776 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 10:14 · PVG 18:14 · LAX 03:14 · JFK 06:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.