tsinghan
V2EX  ›  iOS

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

  •  
  •   tsinghan · Jan 31, 2015 · 3942 views
    This topic created in 4320 days ago, the information mentioned may be changed or developed.

    我看了一下 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 replies  •  2015-02-01 22:26:49 +08:00
    tsinghan
    tsinghan
    OP
    Jan 31, 2015
    2
    var index: NSIndexPath = NSIndexPath(forRow: 1, inSection: 1) 原来这样可以
    ambitiouspei
    ambitiouspei
    Feb 1, 2015
    3
    @tsinghan 开始不熟多看看文档和API,可以下一个dash看着比较方便
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1865 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:29 · PVG 16:29 · LAX 00:29 · JFK 03:29
    ♥ Do have faith in what you're doing.