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 enterFullScreenMode:withOptions: which gives me, method enterFullScreenMode not found.
我一直试图让我的Mac应用程序现在进入全屏幕,但不能让它工作。根据苹果开发者中心的说法,我应该使用enterFullScreenMode:withOptions:这给了我,方法enterFullScreenMode没有找到。
Everywhere I google there seems to be people having issues with making their app fullscreen, so what is the way to make it work?
我在谷歌上的每一个地方,似乎都有人在开发全屏应用时遇到了问题,那么如何让它工作呢?
Edit:
编辑:
Of course enterFullScreenMode
is for the NSView
and I used it on a NSWindow
; it's not the view I want to have fullscreen, but the window. I can't find any function for the NSWindow
though.
当然enterFullScreenMode是针对NSView的我在NSWindow上用过;它不是我想要的全屏视图,而是窗口。但是我找不到NSWindow的任何函数。
4 个解决方案
#1
6
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.
正如在评论中提供的链接中提到的,enterFullScreen:withOptions:有很多缺点会让你想把头发扯下来。实现全屏显示的最佳方法仍然是使用旧的CGDirectDisplay API。Cocoa Dev Central有一篇关于全屏幕应用程序的文章,涵盖了几乎所有你需要知道的东西。
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.
您会注意到这篇文章很古老,而开发工具从那时起就发生了很大的变化(Project Builder!啊,过去的好时光),但是代码本身仍然可以工作。
#2
20
Lion has some new APIs for full screen.
Lion为全屏提供了一些新的api。
To do it with NSWindow, do this
用NSWindow来做这个
[window setCollectionBehavior:
NSWindowCollectionBehaviorFullScreenPrimary];
To do this with NSApplication do this
用NSApplication做这个
[[NSApplication sharedApplication]
setPresentationOptions:NSFullScreenWindowMask];
A bit more about it here.
这里还有一点。
#3
12
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.
现代Mac Os X开发人员(使用故事板)只需要点击他们的main。故事板,选择NSWindow(不是NSWindowController),使用右面板查找属性面板(在标尺的左边,它看起来像一个拖拽工具条),查找“全屏”,选择“主窗口”,而不是它的默认值“Unsupported”。如果需要的话,您也可以设置辅助窗口。
Don't fight the change, use storyboard. One of us... one of us...
不要反对改变,使用故事板。一个人……一个人……
#4
0
[self.view setFrame:[[NSScreen mainScreen] visibleFrame]];
#1
6
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.
正如在评论中提供的链接中提到的,enterFullScreen:withOptions:有很多缺点会让你想把头发扯下来。实现全屏显示的最佳方法仍然是使用旧的CGDirectDisplay API。Cocoa Dev Central有一篇关于全屏幕应用程序的文章,涵盖了几乎所有你需要知道的东西。
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.
您会注意到这篇文章很古老,而开发工具从那时起就发生了很大的变化(Project Builder!啊,过去的好时光),但是代码本身仍然可以工作。
#2
20
Lion has some new APIs for full screen.
Lion为全屏提供了一些新的api。
To do it with NSWindow, do this
用NSWindow来做这个
[window setCollectionBehavior:
NSWindowCollectionBehaviorFullScreenPrimary];
To do this with NSApplication do this
用NSApplication做这个
[[NSApplication sharedApplication]
setPresentationOptions:NSFullScreenWindowMask];
A bit more about it here.
这里还有一点。
#3
12
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.
现代Mac Os X开发人员(使用故事板)只需要点击他们的main。故事板,选择NSWindow(不是NSWindowController),使用右面板查找属性面板(在标尺的左边,它看起来像一个拖拽工具条),查找“全屏”,选择“主窗口”,而不是它的默认值“Unsupported”。如果需要的话,您也可以设置辅助窗口。
Don't fight the change, use storyboard. One of us... one of us...
不要反对改变,使用故事板。一个人……一个人……
#4
0
[self.view setFrame:[[NSScreen mainScreen] visibleFrame]];