我正在OSX 10.7上开发一个应用程序,我试图在第二个屏幕上打开一些图像,而应用程序必须第一个正常运行。Cocoa在第二个屏幕上打开一个全屏窗口,在第一个屏幕上保持应用可见
因此,代码如下:
NSScreen *screen = [[NSScreen screens] objectAtIndex:1];
fullScreenWindow = [[NSWindow alloc] initWithContentRect:[screenFrame]
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO
screen:screen];
[fullScreenWindow setLevel: NSMainMenuWIndowLevel + 1];
[fullScreenWindow setOpaque: YES];
[fullScreenWindow setBackgroundColor:[NSColor yellowColor]];
fullScreenView = [[NSView alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, fullScreenWindow.frame.size.width, fullScreenWindow.frame.size.height)];
// Adding a test button
NSButton *testButton = [[NSButton alloc] initWithFrame(50.0f, 50.0f, 100.0f, 50.0f)];
[testButton setTarget:self];
[testButton setAction:@selector(closeExternalWindow)];
[fullScreenView addSubview:testButton];
// Present the fullscreen window
[fullScreenWindow.contentView addSubview:fullScreenView];
[fullScreenWindow makeKeyAndOrderFront:self];
这样,第一个屏幕上的应用程序显示正确,但第二个屏幕上我只看到一个全屏黑色的窗口。
这是什么问题?
谢谢!
只是一个猜测,但我总觉得这是一种全有或全无的方法,至少没有一款我见过的应用程序。所以,即使它可能是可能的(我怀疑)它会给用户一个非常奇怪的经验,当使用你的应用程序。 – Jay 2013-03-16 08:30:34
嗨周杰伦,谢谢你的回答,但你为什么认为这是一个糟糕的设计? 想到基调,例如,想法是使用第二个屏幕(投影仪)显示一些图像或演示文稿,并使用主屏幕读取数据或运行其他任务。 – 2013-03-16 15:25:32
嗯,好点:-)实际上,iMovie也是这么想的。所以不是完全没有听说过,只是稍微不寻常。 – Jay 2013-03-17 14:58:41