我想显示自定义模式对话框,并做了以下方法:模态定制表不打烊
EncPasswordSheet是IBOutlet中NSWindow的*类型。
@implementation EncryptionPasswordSheet
-(id)init
{
return self;
}
- (void)showCustomDlg:(NSWindow *)window
{
if (!EncPasswordSheet)
{
[NSBundle loadNibNamed: @"EncryptionPasswordDlg" owner: self];
}
[NSApp beginSheet:EncPasswordSheet modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil];
[NSApp runModalForWindow: EncPasswordSheet];
[NSApp endSheet: EncPasswordSheet];
[EncPasswordSheet orderOut: self];
}
- (IBAction)getPasswordFromSheet:(id)sender
{
password = [passwordField stringValue];
[NSApp stopModal];
}
- (IBAction)cancelEncPasswordSheet:(id)sender
{
password = nil;
[NSApp stopModal];
}
@end
正在显示对话框并接受输入。在按下“ok”或“cancel”时,相应的IBAction方法正在执行并且程序继续。问题在于对话框并未避开 - 即没有关闭或消失。
您可能需要重新格式化代码以使其更易于理解。用四个空格缩进来将一些文本格式化为代码。 – jergason 2009-08-27 22:06:07