// @interface MainVC : NSViewController
self.mainVC = [[MainVC alloc]initWithNibName:@"MainVC" bundle:nil];
NSWindow *mainWindow = [NSWindow windowWithContentViewController:self.mainVC];
//@property (nonatomic, strong) NSWindowController *mainWindowController;
self.mainWindowController =[[NSWindowController alloc]initWithWindow:mainWindow];
self.mainVC.view.window.windowController = self.mainWindowController;
[self.mainWindowController.window makeKeyAndOrderFront:self];
[self.mainWindowController.window center];
[self.mainWindowController showWindow:nil];
NSWindow 直接加载NSViewController
最新推荐文章于 2021-09-22 15:01:31 发布
本文介绍了一种在 macOS 应用程序中初始化主视图控制器的方法。通过使用 NSViewController 和 NSWindow 类创建并显示主视图窗口。文章详细展示了如何通过代码分配内存、初始化 nib 文件及设置 window 的 contentViewController。
3555

被折叠的 条评论
为什么被折叠?



