【发布时间】:2020-09-09 11:24:52
【问题描述】:
这可能是一个简单的问题,但请耐心等待,我很新,只是在尝试。 MacOS,不是 iOS,假设我有两个单独的 XIB 文件(MainMenu.xib 和 AnotherWindow.xib)。我正在使用 MainMenu.xib 中的文件菜单打开 AnotherWindow.xib,并在打开时禁用文件菜单:
- (IBAction)OpenAnotherWindow:(id)sender {
if (!anotherWindow) {
anotherWindow = [[AnotherWindow alloc] initWithWindowNibName:@"AnotherWindow"];
}
[anotherWindow showWindow:self];
[self.MenuItem setEnabled:NO];
在 AnotherWindow.xib 中,我想在文件菜单关闭时重新启用:
- (void)windowWillClose:(NSNotification *)aNotification {
[self.MenuItem setEnabled:YES];
}
我遇到的问题是我无法从第二类访问 MenuItem,因为它是 MainMenu.xib 的一部分 - 所以我只是得到错误:在具有 [self.MenuItem setEnabled 的类型的对象上找不到属性:是的];在AnotherWindow.xib中
所以我想我的问题是:如何访问像
这样的属性@property (weak) IBOutlet NSMenuItem *MenuItem;
这是我的 MainMenu.xib 中的 AnotherWindow.xib。
【问题讨论】:
标签: objective-c xcode macos cocoa