gpt4 book ai didi

objective-c - 在 10.9 上打开一个表

转载 作者:行者123 更新时间:2023-12-03 17:12:01 26 4
gpt4 key购买 nike

在我的一个 Controller 中,我想在 10.9 上打开一个模式表。

这是第一个 Controller 的实现代码:

#import "ABSAdvancedPreferencesViewController.h"
#import "ABSUnsyncableWindowController.h"

@interface ABSAdvancedPreferencesViewController ()
@property (strong, nonatomic) ABSUnsyncableWindowController *unsyncableWindowController;
@end

@implementation ABSAdvancedPreferencesViewController

- (id)init {
return [super initWithNibName:@"ABSAdvancedPreferencesViewController" bundle:nil];
}

- (IBAction)showUnsyncableSheet:(id)sender {
if (self.unsyncableWindowController == nil) {
self.unsyncableWindowController = [ABSUnsyncableWindowController new];
}
[self.view.window beginSheet:[self.unsyncableWindowController window] completionHandler:^(NSModalResponse returnCode) {
CLS_LOG(@"Table dismissed");
}];
}

当我执行链接的IBAction时,什么也没有发生。应显示模式的 NSWindowController 子类具有 XIB,启动时可见已停用,并且 window 已经是一个 socket 。

调试我看到这里的window参数是nil,大概是因为我在之前的 Controller 中调用了new:

@implementation ABSUnsyncableWindowController

- (id)initWithWindow:(NSWindow *)window {
self = [super initWithWindow:window];
if (self) {
// Initialization code here.
}
return self;
}

我还可以检查其他内容来显示模式表吗?

最佳答案

您的ABSAdvancedPreferencesViewController init方法缺少将 super 结果分配给自身。另外,为什么不按预期分配/初始化工作表 Controller ?

self.unsyncableWindowController = [[ABSUnsyncableWindowController alloc] initWithWindowNibName:@"XIBNAME"];

这应该分配窗口 Controller ,并且您应该能够访问其窗口进行显示。

关于objective-c - 在 10.9 上打开一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21512183/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com