我在 MainMenu.xib 中有两个窗口
是否可以从第二个窗口上的一个操作按钮关闭两个窗口。??
谢谢
使用 Binding,您可以关闭任何一个,通过 Ctrl+Drag 到窗口并选择performClose:
使用代码,您可以执行以下操作:
创建一个 IBAction 并使用:
- (IBAction)closeAll:(id)sender {
NSLog(@"closing both windows");
[self.secondaryWindow close];
[self.window close];//for primary
}
当然。
创建一个新的 IBAction 并将其作为目标分配给您的按钮。
然后在该 IBAction 中,关闭两个窗口(如果您有指向这些“ NSWindow
”对象的指针或 IBOutlets,则可以这样做)。