我如何解决 Xcode 4.3.1 中的这个新警告:“由于缺少入口点,场景无法访问......”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9746431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:19:00  来源:igfitidea点击:

How do I workaround this new warning in Xcode 4.3.1: "Scene is unreachable due to lack of entry points..."?

xcodeios5warningsuistoryboard

提问by brians

I have an iOS project with a storyboard. I recently upgraded to Xcode 4.3.1, and now this new warning appears:

我有一个带有故事板的 iOS 项目。我最近升级到 Xcode 4.3.1,现在出现这个新警告:

"Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:."

“由于缺少入口点,场景无法访问,并且没有通过 -instantiateViewControllerWithIdentifier: 进行运行时访问的标识符。”

The problem is that I have some Navigation Controllers in the storyboard with no entry points to them. The reason I have them is so that I can embed other views in them to see the nav bar at design time in Xcode. The actual navigation controller these views are pushed onto at runtime are not in the storyboard (old code that hasn't been ported to the storyboard yet).

问题是我在情节提要中有一些导航控制器,但没有它们的入口点。我拥有它们的原因是我可以在其中嵌入其他视图,以便在设计时在 Xcode 中查看导航栏。这些视图在运行时推送到的实际导航控制器不在故事板中(尚未移植到故事板的旧代码)。

Has anyone found a nice workaround for this? I would like to keep my code clean without warnings.

有没有人为此找到一个很好的解决方法?我想在没有警告的情况下保持我的代码干净。

回答by danh

You can just set an identifier. In Xcode >5 on the identity inspector on the right pane, you'll find a field called "Storyboard ID". Put any string in there, and Xcode will be happy again.

您可以只设置一个标识符。在右侧窗格的身份检查器上的 Xcode >5 中,您将找到一个名为“Storyboard ID”的字段。将任何字符串放入其中,Xcode 会再次感到高兴。

It just wants to know you could reach it (via that identifier) if you wanted to.

它只是想知道如果您愿意,您可以(通过该标识符)访问它。

回答by brians

In newer versions of Xcode: Just set a title in Titlein the Attributes Inspector and then set an identifier in the Storyboard IDin the Identity Inspector of your controller.

在较新版本的 Xcode 中:只需Title在属性检查器中设置标题,然后在Storyboard ID控制器的身份检查器中设置标识符。

回答by Josh Benjamin

You may have accidentally copied and pasted a view controller on top of the real one.

您可能不小心将视图控制器复制并粘贴到真实控制器之上。

Try dragging the offending view to see if there's anything underneath.

尝试拖动违规视图以查看下方是否有任何内容。

回答by Terrel Gibson

You can click on the navigation controller and under the attributes inspector click the button "is initial view controller", this should work too

您可以单击导航控制器,然后在属性检查器下单击“是初始视图控制器”按钮,这也应该有效

回答by Ronaldoh1

In Xcode 6 - you might be getting this error if you have a new view controller that is standing by itself. You might have created it and did not use a segue to connect the screen.

在 Xcode 6 中 - 如果您有一个独立的新视图控制器,您可能会收到此错误。您可能已经创建了它并且没有使用 segue 来连接屏幕。

回答by Himanshu Mahajan

You need to set an identifier for each ViewController (including navigation controller) in "Storyboard ID" field of "Identity Inspector" pane.

您需要在“身份检查器”窗格的“故事板 ID”字段中为每个 ViewController(包括导航控制器)设置一个标识符。

In the "Attribute Inspector" pane scroll down to the "View Controller" section and if the "is Initial View Controller" is not checked, check this.

在“属性检查器”窗格中向下滚动到“视图控制器”部分,如果未选中“是初始视图控制器”,请检查此项。

Now run the app.

现在运行应用程序。

回答by EastCoastLife

Title:Setting "is Initial View Controller" (Using Xcode 6.1)

标题:设置“是初始视图控制器”(使用 Xcode 6.1)

Background:Build Failed with "Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:."

背景:构建失败,并显示“由于缺少入口点而无法访问场景,并且没有通过 -instantiateViewControllerWithIdentifier: 进行运行时访问的标识符”。

Just installed Xcode and first time user, so apologize in advance if explanations are lacking appropriate terminology.

刚刚安装 Xcode 和第一次用户,如果解释缺乏适当的术语,请提前道歉。

Resolution:In my case, the "is Initial View Controller" check box was not checked

解决方案:就我而言,未选中“是初始视图控制器”复选框

"is Initial View Controller" property can be found on the far right pane of the default Xcode window or is under --> View --> Utilities --> Show Attribute Inspector

“is Initial View Controller”属性可以在默认 Xcode 窗口的最右侧窗格中找到,或者位于 --> View --> Utilities --> Show Attribute Inspector

If you don't see any properties set in the "Attribute Inspector", select the "View Controller" in the story board area. The little round button with a square in the middle (or the first button on the left)

如果在“属性检查器”中没有看到任何属性设置,请在故事板区域中选择“视图控制器”。中间有一个正方形的小圆形按钮(或左边的第一个按钮)

When you select the "View Controller" you should see that the "Attribute Inspector" box is now populated with various property settings.

当您选择“View Controller”时,您应该会看到“Attribute Inspector”框现在填充了各种属性设置。

In the "Attribute Inspector" pane scroll down to the "View Controller" section and if the "is Initial View Controller" is not checked, check this.

在“属性检查器”窗格中向下滚动到“视图控制器”部分,如果未选中“是初始视图控制器”,请检查此项。

Now Run the project. Hope this helps and works.

现在运行项目。希望这会有所帮助并有效。