OGeek|极客世界-中国程序员成长平台

标题: ios - OS X : Scene is unreachable due to lack of entry points [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 14:00
标题: ios - OS X : Scene is unreachable due to lack of entry points

这个问题可能与 iOS 相关,但不是 OS X。三天来,我一直在努力尝试使用 Storyboard将 NSViewNSViewController 嵌入到 NSView 中。

使用 .xib 或 .nib 可以正常工作按下下一个按钮时,它会在容器 View 中显示 customView1 或 customView2。

nib example

尝试使用 Storyboard 不起作用。事实上,我对如何连接、嵌入、调用、召唤或请求 customView1customView2 让自己进入 Container View 没有任何概念或线索。

storyboard example

似乎我无法访问它自己的 View Controller 之外的任何东西!?!

正常工作功能示例(来自 .nib):

example



Best Answer-推荐答案


这是一种方法。

您可以将两个“容器 View ”对象添加到主视图 Controller ,作为顶级对象,并将它们连接到 Controller 中的 NSView 导出。这将自动创建两个新的 View Controller 场景,Embed 从容器 View 到 subview Controller 。

Interface Builder

您的 View Controller 现在引用了两个内部 NSView,您可以随意操作它们。

如果您需要对 subview Controller 的引用,请为每个 Embed segue 分配一个 Storyboard标识符并实现 -prepareForSegue:sender:

- (void)prepareForSegueNSStoryboardSegue*)segue senderid)sender
{
    if ([segue.identifier isEqual"Embed1"])
    {
        _innerController1 = segue.destinationController;
    }
    else if ([segue.identifier isEqual"Embed2"])
    {
        _innerController2 = segue.destinationController;
    }
}

除了 segues,您可以为每个内部 View Controller 分配一个 Storyboard标识符,并在 Storyboard的代码中实例化它们:

_innerController1 = [self.storyboard instantiateControllerWithIdentifier"InnerController1"];

您还可以自由混合 Storyboard 和 NIB,因此您可以在单独的 NIB 中设计内部 View 并在代码中实例化它们。

关于ios - OS X : Scene is unreachable due to lack of entry points,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28269459/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4