NSApplication endSheet:没有效果
好吧,这确实难倒了我:
我在窗口上创建了一个模态表
-(IBAction) login: (id) sender {
[NSApp beginSheet:loginWindow
modalForWindow:window
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
}
,并尝试将其删除
-(IBAction) loginWindowCancelPressed: (id) sender {
debugLog(@"cancel");
[NSApp endSheet:loginWindow];
}
,但它仍然存在。
我已经检查了所有明显的事情,例如 IB 连接并确保窗口和登录窗口存在且处于正常状态。
所以,问题是:我错过了什么吗?
Ok, this is really stumping me:
I create a modal sheet on a window as
-(IBAction) login: (id) sender {
[NSApp beginSheet:loginWindow
modalForWindow:window
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
}
and try to remove it with
-(IBAction) loginWindowCancelPressed: (id) sender {
debugLog(@"cancel");
[NSApp endSheet:loginWindow];
}
but it remains.
I've checked all of the obvious things like IB connections and ensuring that window and loginWindow are present and in the normal state.
So, the question is: Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须为工作表设置一个委托人。委托应该实现一个具有如下签名的方法:(
如果您愿意,您可以使用不同的名称,但它应该接受相同的参数。)
您可以在该方法中执行您需要执行的任何操作,但最终它应该结束with:
这将关闭该工作表。
You have to set up a delegate for the sheet. The delegate should implement a method with a signature like the following:
(You can use a different name if you like, but it should accept the same parameters.)
You can do whatever you need to do in that method, but ultimately it should end with:
which will dismiss the sheet.
请参阅:在 Cocoa Objective 中创建模态对话框或窗口 - c?
不需要委托。以下内容可以让我驳回并允许稍后回调:
See: Creating a Modal Dialog or Window in Cocoa Objective-c?
A delegate is not required. The following works for me to dismiss and allows calling it back later: