我开发的OSX 10.7的应用程序,我想,目标是到第二个屏幕上打开一些图像,同时应用必须在第一正常运行。
因此,代码如下:
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];
通过这种方式,第一屏幕上的应用程序显示正确,但第二个屏幕上我只看到一个全屏黑色的窗口。
有什么问题?
谢谢!