objective-c – NSWindowController showWindow:nil什么也不做

objective-c – NSWindowController showWindow:nil什么也不做,第1张

概述像标题一样,[myWindowController showWindow:nil]不起作用.以下是您可能需要了解的一些事实: >我的窗口控制器:KRAuthenticationWindowController >界面构建器文件:AuthenticationWindow.xib >文件的所有者是KRAuthenticationWindowController 窗口出口连接到窗口 >窗口的代表连接到文 像标题一样,[myWindowController showWindow:nil]不起作用.以下是您可能需要了解的一些事实:

>我的窗口控制器:KRAuthenticationWindowController
>界面构建器文件:AuthenticationWindow.xib
>文件的所有者是KRAuthenticationWindowController
窗口出口连接到窗口
>窗口的代表连接到文件的所有者
>启动时的窗口可见未被选中
>关闭时的窗口释放也被取消选中

我的代码如下:

// KRApplicationDelegate.m- (voID)applicationDIDFinishLaunching:(NSNotification *)notification {    NSLog(@"%s",__PRETTY_FUNCTION__);    KRAuthenticationWindowController *authWindowController = [[KRAuthenticationWindowController alloc] init];    [authWindowController showWindow:nil];    [[authWindowController window] makeKeyAndOrderFront:nil];}// KRAuthenticationWindowController.m- (ID)init {    self = [super initWithWindowNibname:@"AuthenticationWindow"];    if(!self) return nil;    NSLog(@"%s",__PRETTY_FUNCTION__);    return self;}- (voID)loaDWindow {    [super loaDWindow];    [self.window setBackgroundcolor:[NScolor colorWithDeviceWhite:0.73 Alpha:1]];    NSLog(@"%s",__PRETTY_FUNCTION__);}- (voID)windowDIDLoad {    [super windowDIDLoad];    NSLog(@"%s",__PRETTY_FUNCTION__);}- (voID)showWindow:(ID)sender {    [super showWindow:sender];    NSLog(@"%@",self.window);    NSLog(@"%s",__PRETTY_FUNCTION__);}

我的控制台输出:

2013-02-24 16:21:45.420 Application[3105:303] -[KRApplicationDelegate applicationDIDFinishLaunching:]2013-02-24 16:21:45.421 Application[3105:303] -[KRAuthenticationWindowController init]2013-02-24 16:21:45.428 Application[3105:303] -[KRAuthenticationWindowController loaDWindow]2013-02-24 16:21:45.428 Application[3105:303] -[KRAuthenticationWindowController windowDIDLoad]2013-02-24 16:21:45.556 Application[3105:303] <NSWindow: 0x10016e860>2013-02-24 16:21:45.556 Application[3105:303] -[KRAuthenticationWindowController showWindow:]

我想我只是想念一些重要的东西.任何帮助将不胜感激.

解决方法 尝试将authWindowController转换为实例变量.目前,它是一个局部变量.当局部变量消失时,窗口控制器可能会被释放,窗口被释放,所以它不会被显示出来. 总结

以上是内存溢出为你收集整理的objective-c – NSWindowController showWindow:nil什么也不做全部内容,希望文章能够帮你解决objective-c – NSWindowController showWindow:nil什么也不做所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1249133.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存