How to make a Mac OSX Cocoa application fullscreen?

后端 未结 4 1718
失恋的感觉
失恋的感觉 2021-02-01 19:11

I have been trying to make my Mac application enter fullscreen now for a while but can\'t get it to work. According to the Apple developer center, I should use enterFullScreenMo

相关标签:
4条回答
  • 2021-02-01 19:37

    Lion has some new APIs for full screen.

    To do it with NSWindow, do this

    [window setCollectionBehavior:
              NSWindowCollectionBehaviorFullScreenPrimary];
    

    To do this with NSApplication do this

    [[NSApplication sharedApplication]
            setPresentationOptions:NSFullScreenWindowMask];
    

    A bit more about it here.

    0 讨论(0)
  • 2021-02-01 19:37

    Modern day Mac Os X developers (who use storyboard) need only to click on their main.storyboard, select the NSWindow (not the NSWindowController), Use the right panel to find the attributes panel (the one that to the left of the ruler, it looks like a drag-bar thing) look for "Full Screen" and select "Primary Window" rather than its default value of "Unsupported". You can also set up Auxiliary windows if that's what you want.

    Don't fight the change, use storyboard. One of us... one of us...

    0 讨论(0)
  • 2021-02-01 19:49

    As mentioned in the link Jonathan provided in the comments, enterFullScreen:withOptions: has a number of drawbacks that can make you want to tear your hair out. The best way to do fullscreen is still the older CGDirectDisplay API. Cocoa Dev Central has an article on fullscreen apps that covers pretty much everything you need to know.

    You'll notice the article is pretty ancient and the dev tools have changed a lot since then (Project Builder! Ah, the good old days), but the code itself will still work.

    0 讨论(0)
  • 2021-02-01 19:55
    [self.view setFrame:[[NSScreen mainScreen] visibleFrame]];
    
    0 讨论(0)
提交回复
热议问题