Location of Add/Delete Buttons for an NSTableView in OS X

杀马特。学长 韩版系。学妹 提交于 2021-02-08 01:59:36

问题


I think I must be missing something simple but being new to Xcode... Specifically I am coding in Swift but I believe this is more of a .xib file question. It is easy to have add and delete buttons outside of an NSTableView (like the native Mail app's Preferences->Signatures panel) but how do you integrate these into what seems to be the NSTableView itself? (more like the native Mail app's Preferences->Accounts panel) Ideally I want the option to have more than just add / delete buttons present but once I understand the process adding more functionality should be easy.

Example of Signatures panel vs Accounts panel layout


回答1:


These buttons are not integrated, it's just an NSSegmentedControl aligned to the bottom of the table view.

To get this particular appearance of the NSSegmentedControl

  • Set Style to Small Square
  • Set Mode to Momentary
  • Set the Image of Segment 0 to NSAddTemplate
  • Set the Image of Segment 1 to NSRemoveTemplate
  • Set the width of Segment 0 and 1 to Auto
  • Set the width of Segment 2 to a fixed width.



回答2:


The particular example you showed is just some buttons in a container view abutting the bottom of the scroll view that contains the table view. The container view draws a background to match the buttons and a border. It's probably actually "underlapping" the scroll view by a point so you don't get a doubled border between them.

In fact, if you look carefully, the container view is one point too narrow, so that its right border doesn't match the right border of the scroll view. That kind of proves that it's not part of or in the scroll view.




回答3:


I also had the same question & I posted an answer here :)

But what I think is its a NSView containing 2 NSButtons for + & - as posted in my answer linked above.



来源:https://stackoverflow.com/questions/36523078/location-of-add-delete-buttons-for-an-nstableview-in-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!