How show sheet loaded from xib? (MacOSx)

帅比萌擦擦* 提交于 2019-12-04 09:56:13

I resolve it. You must deactivate almost all the properties of the window object (in the IB) that you are using for the sheet. I add the following method to my controller to show the sheet:

- (void)showInWindow:(NSWindow *)mainWindow {
    if (!panelSheet)
        [NSBundle loadNibNamed:@"XibName" owner:self];

    [NSApp beginSheet:panelSheet modalForWindow:mainWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
    [NSApp runModalForWindow:panelSheet];   //This call blocks the execution until [NSApp stopModal] is called
    [NSApp endSheet:panelSheet];
    [panelSheet orderOut:self];
}

panelSheet is an IBOutlet to the sheet window.

Thanks Jon Hess and JWWalker for your help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!