NSTableViewRowAction-单击后向后滑动

代理商比利

我使用tableView(_:rowActionsForRow:edge:) -> [NSTableViewRowAction]将滑动功能添加到了表格视图中,但是我发现,当单击前导按钮时,它可以正常工作,但不会向后滑动。

这是我的行操作的代码:

extension ViewController: NSTableViewDelegate {
    func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
        // some other codes
        switch edge {
        case .trailing:
            // some other codes
        case .leading:
            let revealInFinderAction = NSTableViewRowAction(style: .regular, title: "Reveal in Finder") { (action, row) in
                self.revealInFinder(row: row)
            }
            revealInFinderAction.backgroundColor = .systemOrange
            return [revealInFinderAction]
        }
    }
}

例如,我的一个按钮执行了“在Finder中显示”作业(revealInFinderAction),单击该按钮后,它在Finder中显示了文件,但没有向后滑动。

我发现苹果的Mail应用程序可以完美地处理此问题,在滑动其中一个单元格后单击“标记为已读/未读”按钮后,它完成了工作并自动向后滑动。我只想找到一种使同一件事发生的方法。

我已经完成了有关如何实现此目标的研究,但是我找不到解决方案,请问有人可以帮助我吗?我在macOS 10.14上使用带有Swift 4的Xcode 10。

伦加德

尝试设置tableView.rowActionsVisible = false,如下所示:

case .leading:
        let revealInFinderAction = NSTableViewRowAction(style: .regular, title: "Reveal in Finder") { (action, row) in
            self.revealInFinder(row: row)
            tableView.rowActionsVisible = false
        }
        revealInFinderAction.backgroundColor = .systemOrange
        return [revealInFinderAction]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章