【问题标题】:Creating NSWindow in fullscreen mode在全屏模式下创建 NSWindow
【发布时间】:2012-01-10 10:03:29
【问题描述】:

有没有办法将 NSWindow 创建为全屏模式? NSWindow 具有 ToggleFullscreen: 选择器,但随后它会正常创建窗口并将其设置为全屏版本,这不是我想要的。还有其他方法吗?

【问题讨论】:

    标签: cocoa xcode4 osx-lion


    【解决方案1】:

    先找到屏幕尺寸

        NSRect screenRect;
        NSArray *screenArray = [NSScreen screens];
        unsigned screenCount = [screenArray count];
        unsigned index  = 0;
    
        for (index; index < screenCount; index++)
        {
            NSScreen *screen = [screenArray objectAtIndex: index];
            screenRect = [screen visibleFrame];
        }
    

    screenRect 包含屏幕大小,现在创建一个窗口并将NSWindow 大小设置为屏幕大小。

    unsigned int styleMask = NSTitledWindowMask 
                               | NSMiniaturizableWindowMask;
    
    
      myWindow = [NSWindow alloc];
      myWindow = [myWindow initWithContentRect: screenRect
                           styleMask: styleMask
                           backing: NSBackingStoreBuffered
                           defer: NO];
      [myWindow setTitle: @"This is a test window"];
    

    【讨论】:

    【解决方案2】:
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
    
        NSRect frame=[NSScreen mainScreen].frame ;
        [self.window setFrame:frame display:YES animate:YES];
    }
    

    这将全屏打开窗口

    【讨论】:

    • 很好,但是如何设置应用程序以使用情节提要全屏启动?
    猜你喜欢
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 1970-01-01
    相关资源
    最近更新 更多