基于文档的应用程序的可可纸

时间:2013-07-10 15:26:41

标签: cocoa document-based

我得到了一个对话框而不是工作表。当应用程序不是基于文档时,它工作。 现在它不起作用。

    - (IBAction) showSheet:(NSWindow*)window
{
    // User has asked to see the dialog. Display it.
    NSLog(@"%@", self.contragentsSheet);
    if (!_contragentsSheet)
        [NSBundle loadNibNamed: @"contragentsSheet" owner: self];
    [NSApp beginSheet:self.contragentsSheet
       modalForWindow: [[NSApp delegate]window]
       //modalForWindow: window
        modalDelegate: self
       didEndSelector: NULL
          contextInfo: NULL];
    //[contragentSearch becomeFirstResponder];
    //NSLog ( @"Sheet is launched");
    NSLog(@"%@", [[NSApp delegate]window]);


}

1 个答案:

答案 0 :(得分:0)

不要使用[[NSApp delegate] window]您需要明确告诉方法要在哪个窗口上显示工作表。基于文档的应用程序可以有多个窗口,并且一个工作表附加到一个窗口。