本文介绍了如何全屏启动NSWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Xcode5中为Mac OSX开发应用程序
I am developing an app for Mac OSX in Xcode5
并且我想以全屏显示我的第一个窗口(没有工具栏只是我的视图)
and I want to display my first Window in fullscreen (no toolbar just my view)
我找到了一种在角落全屏显示按钮的方法:
I found a way to display a button on the corner for fullscreen:
AppDelegate.m:
AppDelegate.m:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
screenFrame = [[NSScreen mainScreen] frame];
[self.window setBackgroundColor: NSColor.whiteColor];
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[[self window] setFrame:screenFrame display:YES];
}
但是要全屏显示,我必须单击角落的按钮
but to get fullscreen I have to click on the corner's button
如何全屏保存按该按钮的步骤?
how to get fullscreen saving the step of pressing that button?
推荐答案
添加此[self.window toggleFullScreen:self];
add this [self.window toggleFullScreen:self];
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
screenFrame = [[NSScreen mainScreen] frame];
[self.window setBackgroundColor: NSColor.whiteColor];
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[self.window setFrame:screenFrame display:YES];
[self.window toggleFullScreen:self];
}
这篇关于如何全屏启动NSWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!