框架与厦门国际银行
我在我的框架中面临一个关于 XIB 文件的奇怪问题。该 XIB 文件包含一个 NSWindow
、NSTableView
和两个按钮,所有这些按钮都通过 Outlet 连接。 TableView 和 Button 按预期工作,但 NSWindow
始终为 (null)
。
窗口的插座已连接并且XIB 正在正确加载,所以我真的很惊讶这对于这个特定实例不起作用。
我像这样加载 XIB: BOOL success = [NSBundle loadNibNamed:@"SomeXIB" Owner:self];
然后我尝试修改窗口:
[window setLevel:NSModalPanelWindowLevel];
[window center];
[window makeKeyAndOrderFront:self];
NSLog(@"Window: %@",window);
NSLog
语句始终返回(null)
并且上面的方法都没有执行任何操作,该窗口仅显示,因为选中了 Visible At Launch
,否则不会显示。 (这证明 XIB 加载正常)
我错过了什么吗?
编辑:
这是我对窗口所做的所有操作:
BOOL success = [NSBundle loadNibNamed:@"BrowserPrompt" owner:self];
if (success == NO)
{
NSLog(@"Couldn't load XIB.");
return NO;
}
[[self delegate] pickerWillShow:self];
[window setLevel:NSModalPanelWindowLevel];
[window center];
[window makeKeyAndOrderFront:self];
I'm facing a strange problem concerning a XIB file in my framework. This XIB file contains a NSWindow
, NSTableView
and two buttons, all of which are connected via Outlets. The TableView and Buttons work as expected, but the NSWindow
is always (null)
.
The window's outlet is connected and the XIB is being loaded correctly, so I'm really surprised that this doesn't work for this particular instance.
I load the XIB like this: BOOL success = [NSBundle loadNibNamed:@"SomeXIB" owner:self];
Then I try to modify the window:
[window setLevel:NSModalPanelWindowLevel];
[window center];
[window makeKeyAndOrderFront:self];
NSLog(@"Window: %@",window);
The NSLog
statement always returns (null)
and none of the methods above do anything, the window only shows up because Visible At Launch
is checked and won't otherwise. (which proves that the XIB is loaded fine)
Am I missing something?
Edit:
Here's all I do to the window:
BOOL success = [NSBundle loadNibNamed:@"BrowserPrompt" owner:self];
if (success == NO)
{
NSLog(@"Couldn't load XIB.");
return NO;
}
[[self delegate] pickerWillShow:self];
[window setLevel:NSModalPanelWindowLevel];
[window center];
[window makeKeyAndOrderFront:self];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几乎可以肯定,以下情况之一是正确的:
self.window
不是 IBOutletself
不是同一类窗口
IBOutlet。window
设置为nil
。重写 setWindow: 以便您可以放入日志记录或断点,并确保它被调用,并检查是否使用 nil 或正确的值调用它。
Almost certainly, one of the following is true:
self.window
is not an IBOutletself
window
IBOutlet.window
tonil
between the load and the usage.Override
setWindow:
so you can put in logging or a breakpoint, and make sure it's being called, and check whether it's being called withnil
or a proper value.