Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 为什么应用程序窗口只打开一次,然后再也不打开?_Objective C_Cocoa - Fatal编程技术网

Objective c 为什么应用程序窗口只打开一次,然后再也不打开?

Objective c 为什么应用程序窗口只打开一次,然后再也不打开?,objective-c,cocoa,Objective C,Cocoa,我正在根据一本书中的教程创建一个应用程序,但我注意到一个问题,当我创建的首选项窗口打开然后关闭时,它将不会再次打开,我如何解决这个问题 谢谢 编辑:我看到了另一篇关于这个的帖子,但仍然没有得到回复,所以我想知道你是否可以帮我回答这个问题 编辑:我说的是一个面板(用作首选项窗格),它通过菜单项打开,并在窗口的一角用十字符号关闭。我用来创建它的代码来自《MacOSX的Cocoa编程》一书,用作首选项窗格的面板位于单独的nib文件中 编辑:这是代码,它很复杂,因为教程让你创建了4个文件 1)首选项\u

我正在根据一本书中的教程创建一个应用程序,但我注意到一个问题,当我创建的首选项窗口打开然后关闭时,它将不会再次打开,我如何解决这个问题

谢谢

编辑:我看到了另一篇关于这个的帖子,但仍然没有得到回复,所以我想知道你是否可以帮我回答这个问题

编辑:我说的是一个面板(用作首选项窗格),它通过菜单项打开,并在窗口的一角用十字符号关闭。我用来创建它的代码来自《MacOSX的Cocoa编程》一书,用作首选项窗格的面板位于单独的nib文件中

编辑:这是代码,它很复杂,因为教程让你创建了4个文件

1)首选项\u Delegate.h

#import <Cocoa/Cocoa.h>
@class PreferenceController;

@interface Prefernces_Delegate : NSObject {
    PreferenceController *preferenceController;
}
- (IBAction)showPreferencePanel:(id)sender;

@end
3)首选控制器.h(不重要)


在界面生成器中,确保在窗口的属性中禁用了“关闭时释放”。同时,再次检查您的窗口控制器与窗口之间的连接是否连接正常。

确保windowController中的窗口变量已连接到面板。

您可能需要为这个问题添加一些上下文。什么时候开门?你怎么关的?你用什么方法打开它?你是故意含糊其辞吗?“真正的基础应用程序”?“窗口打开后又关闭,不会再打开”?“看到另一篇关于这个的帖子了吗”?有那么多可能的情况,你可以参考,这是荒谬的。不,只是更新了一些更多的信息的第一篇文章。你希望这个问题有多大,你不希望问题太长,因为没有人会看它。我不太了解可可,但从什么时候起,有人在Intertube上停止了?是否有可能,虽然窗口正在关闭,但应用程序本身没有清理并退出?我如何连接窗口?因为它在教程中没有提到任何内容。谢谢,你是对的,我错过了教程中告诉你连接窗口的一个步骤。
#import "Prefernces_Delegate.h"
#import "PreferenceController.h"

@implementation Prefernces_Delegate

- (IBAction)showPreferencePanel:(id)sender
{
    // Is preferenceController nil?
    if (!preferenceController) {
        preferenceController = [[PreferenceController alloc] init];
    }
    NSLog(@"showing %@", preferenceController);
    [preferenceController showWindow:self];
}

@end
#import <Cocoa/Cocoa.h>
@interface PreferenceController : NSWindowController {
    IBOutlet NSButton *checkbox;
}
- (IBAction)changeNewEmptyDoc:(id)sender;
@end
#import "PreferenceController.h"


@implementation PreferenceController

- (id)init
{
    if (![super initWithWindowNibName:@"Preferences"])
        return nil;
    return self;
}
- (void)windowDidLoad
{
    NSLog(@"Nib file is loaded");
}
- (IBAction)changeNewEmptyDoc: (id)sender
{
    int state = [checkbox state];
        NSLog(@"Checkbox changed %d", state);
}




@end