代码之家  ›  专栏  ›  技术社区  ›  Trombone0904

使用nsbutton选择大纲视图行

  •  -2
  • Trombone0904  · 技术社区  · 9 年前

    我正在为osx使用swift 4。 每个单元格中都有一个按钮。

    在我的大纲视图控制器类中,是此按钮的IBAction操作:

    @IBAction func showInfo(_ sender: NSButton) {     
    
       // Get the row of clicked button
       print(myOutlineView.row(for: sender as NSView))
    
    }
    

    我想我必须使用这个命令:

    myOutlineView.selectRowIndexes(<NSIndexSet>, byExtendingSelection: <Bool>)
    

    但是我如何获得NSIndexSet值呢?

    1 回复  |  直到 9 年前
        1
  •  -2
  •   Trombone0904    9 年前

    好的,我找到了解决方案:

    myOutlineView.selectRowIndexes(IndexSet(integer: myOutlineView.row(for: sender as NSView)), byExtendingSelection: false)
    
    推荐文章