NSWindow beginSheet完成处理程序未调用 [英] NSWindow beginSheet completionHandler not called

查看:234
本文介绍了NSWindow beginSheet完成处理程序未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在主窗口中显示一张纸.我使用以下代码显示工作表:

I am showing a sheet within my main window. I present the sheet using this code:

AddContactWindowController *addContact = [[AddContactWindowController alloc] initWithWindowNibName:@"AddContactWindow"];
addContact.currentViewController = myView;
self.addWindowController = addContact;

[self.view.window beginSheet: addContact.window completionHandler:^(NSModalResponse returnCode) {
    NSLog(@"completionHandler called");
}];

AddContactWindowController是NSWindowController的子类.它内部有一个视图控制器.视图内部是一个关闭"按钮,它会调用此按钮:

AddContactWindowController is a NSWindowController subclass. It has a view controller within it. Inside the view is a "close" button which invokes this:

[[[self view] window] close];

这确实关闭了窗口,但是未调用beginSheet中的completionHandler.这给我带来了很多麻烦.

This does close the window, but the completionHandler from beginSheet is not invoked. This causes me problems down the road.

有什么特别的方法可以关闭NSWindow工作表以便成功调用完成处理程序?我也尝试过[[[self view] window] orderOut:self],但这也不起作用.

Is there any particular way we should close the NSWindow sheet for the completion handler to be successfully called? I've also tried [[[self view] window] orderOut:self] but that doesn't work either.

谢谢.

推荐答案

您将要调用

You will want to call -endSheet:returnCode: on your window, rather than just ordering it out.

这篇关于NSWindow beginSheet完成处理程序未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆