如何关闭从 NSWindowController 启动的 window
How to close window fired up from NSWindowController
非常棘手的问题:我想在发送 HTTP POST 正文数据后以编程方式关闭 window。我阅读了文档并实现了该方法
- (void) performClose : ( id ) 发件人;
和
- ( BOOL ) windowShouldClose : ( id ) 发件人;但从来没有叫过。所以请你能从下面提供的代码中让我朝着正确的方向前进以实现 mi 目标吗?
感谢您的黄金时间。
我的代码:
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
//.h
@interface PostinoClass : NSWindowController <NSURLSessionDataDelegate, NSURLConnectionDelegate,NSURLSessionTaskDelegate,NSURLConnectionDataDelegate> {
NSWindowController *controllerWindow;
}
//.m
- (void)openWindow {
// NSLog(@"openWindow");
controllerWindow = [[NSWindowController alloc]initWithWindowNibName:@"SendEmailWindow"];
[controllerWindow showWindow:self];
}
//现在我可以打开我的酷window,但需要在一些肮脏的工作之后关闭...
- (void)closeWindow:(id)sender {
// NSLog(@"closeWindow");
// [controllerWindow close]; // not work <--
[controllerWindow.window performClose:sender]; //not work too <--
}
[[self window] close];
就是这样。
文档 link.
非常棘手的问题:我想在发送 HTTP POST 正文数据后以编程方式关闭 window。我阅读了文档并实现了该方法 - (void) performClose : ( id ) 发件人; 和 - ( BOOL ) windowShouldClose : ( id ) 发件人;但从来没有叫过。所以请你能从下面提供的代码中让我朝着正确的方向前进以实现 mi 目标吗? 感谢您的黄金时间。
我的代码:
#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
//.h
@interface PostinoClass : NSWindowController <NSURLSessionDataDelegate, NSURLConnectionDelegate,NSURLSessionTaskDelegate,NSURLConnectionDataDelegate> {
NSWindowController *controllerWindow;
}
//.m
- (void)openWindow {
// NSLog(@"openWindow");
controllerWindow = [[NSWindowController alloc]initWithWindowNibName:@"SendEmailWindow"];
[controllerWindow showWindow:self];
}
//现在我可以打开我的酷window,但需要在一些肮脏的工作之后关闭...
- (void)closeWindow:(id)sender {
// NSLog(@"closeWindow");
// [controllerWindow close]; // not work <--
[controllerWindow.window performClose:sender]; //not work too <--
}
[[self window] close];
就是这样。
文档 link.