ios - 操作系统 X : Scene is unreachable due to lack of entry points

标签 ios objective-c xcode macos storyboard

这个问题可能与 iOS 相关,但不是 OS X。我花了三天时间尝试简单地尝试使用 Storyboard将 NSViewNSViewController 嵌入到 NSView 中。

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

nib example

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

storyboard example

看来我无法访问它自己的 View Controller 之外的任何内容!?!

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

example

最佳答案

这是一种方法。

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

Interface Builder

您的 View Controller 现在拥有对两个内部 NSView 的引用,您可以根据需要操纵它们。

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

- (void)prepareForSegue:(NSStoryboardSegue*)segue sender:(id)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 - 操作系统 X : Scene is unreachable due to lack of entry points,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28269459/

相关文章:

iOS Carthage 提交到 App Store 问题 : Unsupported Architecture, Invalid Segment Alignment

iphone - UITableView 多选。使用所选行自动选择随机行

ios - iPhone 核心位置架构 - 如何跨多个 Controller 使用它

iphone - UIActivityController 是如何呈现的?

iphone - iOS 帮助 : loaded the nib but the view outlet was not set

iphone - Command/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 失败,退出代码为 1

objective-c - NSTimer 触发 UIProgressView 失败

ios - arc4random() 在 iOS 中给出负数

objective-c - NSNotification 上的对象是否需要强制转换?

objective-c - 2 目标 1 图标名称