0

我目前正在开发一个待办事项类型应用程序的原型。我有一个包含用户任务的表。我想做的只是向用户提供相关的任务信息。但要编辑其他信息,他们会点击披露按钮来展开单元格。

我在想两种可能的方法来处理这个问题:

  • 扩展 NSTableViewCell
  • 使用 NSStackView 作为每个单元格的内容

如果使用 NSTableViewCell,我可能会有两个 NSView 来表示单元格(顶部和底部)。

如果使用 NSStackView,我将有一种简单的方法来封装这些部件。

我想另一种方法也可以完全用 NSStackView 构建它。

更困难的方面似乎与细胞的实际膨胀/塌陷有关。

我知道这可以被视为征求意见的问题类型。我从未构建过 MacOS 应用程序。因此,我正在寻找一些关于解决问题的最佳方法的指导,而不是在注定不会有成效的方法上旋转我的车轮。

谢谢!

4

1 回答 1

0

In the end, it looks like the best thing to do is use an NSTableCellView with two NSViews for the top and bottom half. I had the case of this as well as the NSStackView working. But in the end, I found that using NSStackView to collapse or expand requires a call to make noteHeightOfRows work anyways.

So it would initially seem that it's not worth the effort of expanding it unless I have a more complicated cell where say I wanted a top, middle, and bottom, where the middle could expand and contract. While I would still need to use noteHeightOfRows, it would allow for it.

However, there is one benefit of using the NSStackView. The animation is much smoother for the collapse. I've found the NSTableCellView method with a top and bottom NSView shows signs of "tearing" as it collapses. This is what appears in the bottom edge, while horizontal, jitters. This is particularly apparent if you either spam the button or if the cell is selected because the bottom of the outline can sometimes grow in height.

I also found that when using NSAnimationContext to help make it look a little smoother, I'd see strange behavior. Like the hide would happen at the wrong time (even though it was in the completionHandler. I think the root cause of that are what becomes overlapping animations.

于 2019-08-07T03:19:31.603 回答