在 NSSplitView 中设置视图不起作用

发布于 2024-11-09 23:10:38 字数 614 浏览 0 评论 0原文

请原谅我的无知,我是从 iOS 转向 Mac 编程的。我有两个笔尖。一种是具有分割视图的主窗口。笔尖包含我创建的 navigationController 视图。我试图用此视图替换分割视图(navigationView)的右窗格。当应用程序首次启动时,navigationView 只是界面构建器中的自定义视图。

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NavigationController *navController = [[NavigationController alloc]
                                           initWithNibName:@"NavigationController" 
                                           bundle:[NSBundle mainBundle]];
    navigationView = navController.view;
}

这似乎没有什么作用。我尝试将 navController.view 添加为子视图,这至少让它显示出来,但它的放置非常奇怪。有什么建议吗?谢谢!

Please excuse my ignorance, I'm coming from iOS to Mac programming. I have two nibs. One is the main window with the split view. The nib contains a navigationController view I created. I'm trying to replace the right pane of the split view (navigationView) with this view. When the application first launches, navigationView is just a custom view in interface builder.

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NavigationController *navController = [[NavigationController alloc]
                                           initWithNibName:@"NavigationController" 
                                           bundle:[NSBundle mainBundle]];
    navigationView = navController.view;
}

This doesn't seem to do anything. I tried adding the navController.view as a subview, and that at least gets it showing up, but it is placed very oddly. Any suggestions? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

面如桃花 2024-11-16 23:10:38

您肯定必须在 NSSplitView 中添加所需的视图作为 NSSplitView 的子视图。您需要提供有关此后发生的情况的更多信息。

Apple 网站上有很多示例代码,其中许多都使用 NSSplitViews。

You will definitely have to add the views you want in the NSSplitView as a subviews of the NSSplitView. You'll need to provide more information about what happens after that.

There's lots of sample code on Apple's website and many of them use NSSplitViews.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文