我的应用程序中有 NSOutlineView。这个功能
-(BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item
将outlineView中的一些项目设置为组根(如果函数返回YES)+在单元格末尾添加显示/隐藏按钮以展开/折叠该组的内容,但是这个按钮是用英文写的。我来自白俄罗斯,这就是为什么我想要显示/隐藏用我的语言写的单词。 Finder 以我的语言编写,这就是为什么我认为,有一些选项可以为其设置本地化样式。 我该怎么做?
已解决:
Mac OS 在选择包含 NSOutineView
最佳答案
检索本地化显示/隐藏按钮(以及披露按钮)的官方方法现在是 documented在 NSOutlineView 类引用中。
let showHideButton = outlineView.makeViewWithIdentifier(NSOutlineViewShowHideButtonKey, owner: outlineView.delegate()) as? NSButton
重要的是要注意按钮的 state
属性控制隐藏/显示标题,默认情况下它不会与 NSOutlineView 的状态同步:
NSOnState
= "隐藏"NSOffState
= "显示"
NSOutlineViewDisclosureButtonKey
The normal triangle disclosure button.
NSOutlineViewShowHideButtonKey
The Show/Hide button.The outline view creates these buttons by calling its inherited
makeViewWithIdentifier:owner:
method, passing in the key as the identifier and the delegate as the owner.These keys are backwards compatible to OS X v10.7, however, the symbol is not exported prior to v10.9 and the string value (@"NSOutlineViewDisclosureButtonKey") must be used.
关于objective-c - 如何在 NSOutlineView 中设置本地化的显示/隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8631982/