How to disable NSDocument's window title popup

2019-04-27 13:33发布

I have an NSDocument based app with autosave enabled.

I'd like to prevent this popup from showing: autosave popup

I have tried returning nil from NSWindow's –title, –representedFilename and –representedURL which hide the title effectively hide the title but have no effect on the downward facing disclosure indicator and the popup.

Is there a way I can prevent this popup from being presented?

3条回答
We Are One
2楼-- · 2019-04-27 14:09

I was able to prevent the button from being shown by overriding NSWindow's

+ (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKind forStyleMask:(NSUInteger)windowStyle

and returning nil for NSWindowDocumentVersionsButton

查看更多
神经病院院长
3楼-- · 2019-04-27 14:14

Return false from NSDocument's autosavesInPlace() override

查看更多
唯我独甜
4楼-- · 2019-04-27 14:25

You can also use a streamlined toolbar (wwdc2016)

  override func viewWillAppear() {
        super.viewWillAppear()

        self.view.window!.titleVisibility = .hidden  
  }

This removes also the title bar (but not the ones of tabbed windows)

查看更多
登录 后发表回答