Creating a Modal Dialog or Window in Cocoa Objective-C?

后端 未结 2 586
闹比i
闹比i 2021-02-01 21:48

I need to create an modal dialog, which is to loaded from a nib file and should be displayed on a button click in the main window.

I can create a custom window in a nib

2条回答
  •  梦毁少年i
    2021-02-01 22:49

    Thank you...

    (Example). Create a nib with name "About"

    if(pAbtCtrl == nil)
            pAbtCtrl = [[AboutWindowController alloc] initWithWindowNibName:@"About"];
    
    pAbtWindow = [pAbtCtrl window];
    
    [NSApp runModalForWindow: pAbtWindow];
    
    [NSApp endSheet: pAbtWindow];
    
    [pAbtWindow orderOut: self];
    

提交回复
热议问题