我正在 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];
这样,在第一个屏幕上应用程序正确显示,但在第二个屏幕上我只看到一个全屏黑色窗口。
有什么问题?
谢谢!