How do I disable the Show Tab Bar menu option in Sierra apps?

吃可爱长大的小学妹 提交于 2019-12-03 23:47:58

You can also do this on IB, on the Window’s attributes inspector

On 10.12, you need to now set the following when the window is created as Tab Bar is now available by default:

[NSWindow setAllowsAutomaticWindowTabbing: NO];

If you don't want to compile against the latest frameworks, you can use the following code in your NSWindowsController sub classes:

Swift:

 override func awakeFromNib() {
     if NSAppKitVersionNumber > 1500 {
        self.window?.setValue(2, forKey: "tabbingMode")
     }
 }

Objective-C:

- (void)awakeFromNib {
    if (NSAppKitVersionNumber > 1500) {
        [self.window setValue:[NSNumber numberWithInt:2] forKey:@"tabbingMode"];
    }
}

To disable tabbing on individual windows call setTabbingMode:

if([window respondsToSelector:@selector(setTabbingMode:)]) {
    // this particular window doesn't support tabbing in Sierra.
    [window setTabbingMode:NSWindowTabbingModeDisallowed];
}

Swift solution:

override func awakeFromNib() {
    super.awakeFromNib()
    if #available(OSX 10.12, *) {
        tabbingMode = .disallowed
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!