【问题标题】:get row number of dragged row in tableview获取tableview中拖动行的行号
【发布时间】:2017-06-24 14:11:10
【问题描述】:

我有两个表视图,您可以在其中将一行从表 A 拖到表 B。 这很好用。

但我需要知道,将从表 A 中拖出哪个行号。 这是我的表 A 的代码,也是问题:

func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
   pboard.declareTypes([NSStringPboardType],owner: nil)
   pboard.setString(persons[0].objectID.uriRepresentation().absoluteString, forType: NSStringPboardType)
        return true
}

此刻我总是拖着“人”的第一个元素 我需要一个解决方案,我可以设置一个行号(或类似的东西)而不是静态的“persons [0]”。

有什么办法吗?

【问题讨论】:

  • rowIndexes 怎么样?
  • 是的,我认为这是正确的方法,但我不知道如何使用它。人 [rowIndexes] 不起作用
  • 好的,我知道了:persons[rowIndexes.first]

标签: macos cocoa swift3 drag-and-drop tableview


【解决方案1】:

你试过persons[rowindexes.first]吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多