1

我有首选项窗格应用程序,需要使用特定的 nib 文件显示模式窗口。

我使用方法:

[NSBundle loadNibNamed:@"___NibName___" owner:self];    

没关系,但窗口不是模态的(我可以访问首选项窗格窗口)。

我应该点什么来使这个窗口模态化(用户不应该有权访问首选项窗格窗口,直到当前窗口不会关闭)。

谢谢!

4

2 回答 2

1

Easiest way to do and manage afterwards: create a new NSWindowController, set this class as File's owner in your custom nib/xib, connect the window outlet to your window within the nib/xib, get the window reference by first creating an instance of your class and then using

NSWindow *window = instance.window;

Then run it modal with NSApplication's

runModalForWindow:
于 2012-05-28T18:46:17.107 回答
0

如果你在iOS

如果要将其显示为模式,则必须有一个单独的视图控制器来管理该 nib 文件。一旦你有了那个视图控制器的一个实例,用这个来展示它:

 aViewControllerClasss *sampleView= [[aViewControllerClasss alloc] initWithNibName:@"___yournibname___" bundle:nil];
 //set any variables of the new view controller(such as delegate) here, before you present it. 
 [self presentModalViewController:sampleView animated:YES];
 [sampleView release];
于 2012-05-28T13:27:25.827 回答