ios Xcode:“由于缺少入口点,无法到达场景”但找不到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13531035/
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
Xcode: "Scene is unreachable due to lack of entry points" but can't find it
提问by Wolfy
Xcode 4.5.2 gives me the following warning:
Xcode 4.5.2 给了我以下警告:
Unsupported Configuration
Scene is unreachable due to lack of entry points and does not have an identifier
for runtime access via -instantiateViewControllerWithIdentifier:.
Unfortunately I can't identify the incriminated scene. Selecting the warning in the Issue Navigator doesn't highlight anything in the Storyboard. I have a fairly complicated storyboard (30+ scenes).
不幸的是,我无法确定被指控的场景。在问题导航器中选择警告不会突出故事板中的任何内容。我有一个相当复杂的故事板(30 多个场景)。
Any suggestions?
有什么建议?
采纳答案by Bob H
While this thread is old, I didn't see an answer describing what worked for me, so here goes...
虽然这个线程很旧,但我没有看到描述对我有用的答案,所以这里是......
I had this error and visual examination of the storyboard showed that all of the view controllers appeared to be connected to the root view controller.
我遇到了这个错误,对故事板的视觉检查显示所有视图控制器似乎都连接到根视图控制器。
I tried naming all 17 of the view controllers in the storyboard (as in @bobnoble's answer). I used a naming convention based on the long name of the view controller, e.g. "jvc" for "Jobs View Controller". When I tried to build, I got an error message pointing to one of the view controllers as having a duplicate name. Tracking things down, I found that I had an actual duplicateof a view controller stacked exactly on top of its twin. I suspect it was cut-and-paste damage from a user interface experiment that I didn't back out completely.
我尝试命名故事板中的所有 17 个视图控制器(如@bobnoble 的回答)。我使用了基于视图控制器长名称的命名约定,例如“jvc”代表“Jobs View Controller”。当我尝试构建时,我收到一条错误消息,指出其中一个视图控制器具有重复的名称。追踪事情,我发现我有一个视图控制器的实际副本,正好堆叠在它的双胞胎之上。我怀疑这是我没有完全退出的用户界面实验的剪切和粘贴损坏。
Anyway, deleting the unconnected twin solved my problem. After that, I removed all of the VC names as they're not referenced in the code.
无论如何,删除未连接的双胞胎解决了我的问题。之后,我删除了所有 VC 名称,因为它们没有在代码中引用。
回答by bobnoble
In your storyboard, select each of the view controller (red arrow in image below) and look at the Storyboard ID field (red oval). None of the Storyboard ID fields should be blank. When you find one that is, that is the culprit.
在故事板中,选择每个视图控制器(下图中的红色箭头)并查看故事板 ID 字段(红色椭圆形)。任何故事板 ID 字段都不应为空。当你找到一个,那就是罪魁祸首。
回答by w0mbat
I just had this exact error with a simple single-scene Storyboard, and all I had to do to fix it was check the "Is Initial View Controller" checkbox for the 1 view controller in the Storyboard. I suspect Xcode used to check this box for you by default in this situation, but no longer does.
我刚刚在一个简单的单场景故事板中遇到了这个确切的错误,我所要做的就是检查故事板中 1 个视图控制器的“是初始视图控制器”复选框。我怀疑在这种情况下,Xcode 曾经默认为您选中此框,但现在不再这样做了。
?????????????????????????????????????
??????????????????????????????????????????
Check the box for exactly one of the view controllers in your storyboard and you should be good.
选中故事板中正好有一个视图控制器的框,你应该很好。
回答by Scott Berrevoets
I'm afraid you'll have to go through all 30 of them, and check whether they have a Storyboard ID or a segue to that view controller. One of the two is required, both is also an option.
恐怕您必须遍历所有 30 个,并检查它们是否具有 Storyboard ID 或该视图控制器的 segue。两者之一是必需的,两者也是一种选择。
回答by shah1988
This issue can happen in one the following scenarios:
在以下情况之一中可能会发生此问题:
Case I:If none of the scene in the storyboard is marked as "isInitialViewController".
情况一:如果情节提要中的场景都没有标记为"isInitialViewController"。
Fix: Identify the root view controller and mark it as "isInitialViewController"in your SB. In this case storyboard id is is not mandatory.
修复:识别根视图控制器并在您的 SB 中将其标记为“isInitialViewController”。在这种情况下,故事板 ID 不是强制性的。
Case II
案例二
There can be situations where you do not need to have a initialViewController in a storyboard. For eg: when using Multiple storyboards.
在某些情况下,您不需要在故事板中使用 initialViewController。例如:当使用多个故事板时。
Fix: In such cases make sure the "storyboard id"is correctly given and you refer to the first scene to used in the storyboard using this id. For eg:
修复:在这种情况下,请确保正确给出“故事板 ID”,并使用此 ID 引用故事板中使用的第一个场景。例如:
UIStoryboard *myStoryBoard = [UIStoryboard storyboardWithName:@"MyStoryBoardName" bundle:nil];
MyViewController *myViewController = (MyViewController *)[myStoryBoard instantiateViewControllerWithIdentifier:@"MyViewControllerId"];
In this case "storyboard id"is mandatory.
在这种情况下,“storyboard id”是强制性的。
Case III
案例三
You have your initialViewController connected. But still you get this warning. This is because some of the scenes in the storyboard may not be connected with a "segue"and also they do not have a "storyboard id". Scan your storyboard, see if a "segue"is needed. Connect the segue if that is missing. If a segue is not needed make sure you need to give a "storyboard id"since it is the only way to refer the scene from your code, as shown in the example code above.
您已经连接了 initialViewController。但是您仍然会收到此警告。这是因为故事板中的某些场景可能没有与“segue”相关联,而且它们也没有“故事板 id”。扫描你的故事板,看看是否需要“segue”。如果缺少,请连接 segue。如果不需要转场,请确保您需要提供“故事板 id”,因为这是从代码中引用场景的唯一方法,如上面的示例代码所示。
Hope this helps
希望这可以帮助
回答by Kampai
You don't need to set Storyboard ID
for all scenes or UINavigationController
您不需要Storyboard ID
为所有场景设置或UINavigationController
Well I have around 50-60 scenes and I just got these warning so that I realise that only the controller(Scene) or NavigationController which is not connected with segue needs to set Storyboard ID
.
好吧,我有大约 50-60 个场景,我刚刚收到这些警告,因此我意识到只有未与 segue 连接的控制器(场景)或 NavigationController 需要设置Storyboard ID
.
You can see that in above image UINavigationController
is not connected with segue, it was a culprit of that warning.
您可以看到在上图中UINavigationController
没有与 segue 连接,它是该警告的罪魁祸首。
Just give it a Storyboard ID to remove this warning.
只需给它一个 Storyboard ID 即可删除此警告。
回答by Richard
I had the same issue. I've got lots of views on my storyboard with a nav and tab bar controller. For me it was just be a warning to let you know that some of the views are not connected. Make sure all your views are connected in some way to the root view controller. I was starting this project from scratch to eliminate this warning and noticed the same warning when a view wasn't connected.
我遇到过同样的问题。我的故事板上有很多视图,带有导航和标签栏控制器。对我来说,这只是一个警告,让您知道某些视图没有关联。 确保所有视图都以某种方式连接到根视图控制器。我从头开始这个项目以消除此警告,并在未连接视图时注意到相同的警告。
回答by ajay14
Simplest way to find the offending scene:
找到违规场景的最简单方法:
Go to the issue navigator (in the left panel, next to the search button), and double click the error. A window will popup containing the offending scene centered in the middle of the window.
转到问题导航器(在左侧面板中,搜索按钮旁边),然后双击错误。将弹出一个窗口,其中包含位于窗口中间的违规场景。
(This is actually generally true - double clicking any error will generally result in a popup containing the error centered - a neat little trick!)
(这实际上通常是正确的 - 双击任何错误通常会导致一个包含错误居中的弹出窗口 - 一个巧妙的小技巧!)
Side note: Sometimes, XCode will incorrectly give this error for a scene that is the root view controller of a navigation controller (that is the initial view controller). Simple fix is giving this root view controller a Storyboard ID, compiling (error should go away), and then removing the storyboardID (no error anymore).
旁注:有时,对于导航控制器(即初始视图控制器)的根视图控制器的场景,XCode 会错误地给出此错误。简单的修复是给这个根视图控制器一个 Storyboard ID,编译(错误应该消失),然后删除 storyboardID(不再有错误)。
回答by Dmitry Minkovsky
The easiest way to see which controller, or scene, is causing this problem is by:
查看导致此问题的控制器或场景的最简单方法是:
- Ctrl-clicking your
.storyboard
in the Project Navigator and selectingOpen As > Source Code
. This will bring up the underlying XML of the Storyboard. - In this view, the warning will be clearly related to a line in the XML that relates to the offending scene.
.storyboard
在项目导航器中按住 Ctrl 键并单击您的项目并选择Open As > Source Code
. 这将调出 Storyboard 的底层 XML。- 在此视图中,警告将与 XML 中与违规场景相关的一行明显相关。
Now, in my case, the warning was particularly annoying because the "offending scene" had an identifier and a segue! I was able to remedy the problem by deleting the scene and then undoing the deletion. Not elegant, but worked. I saved my Storyboard before doing this. In retrospect, I should have made a copy and diff
'd the before-after.
现在,就我而言,警告特别烦人,因为“令人反感的场景”有一个标识符和一个转场!我能够通过删除场景然后撤消删除来解决问题。不优雅,但有效。在执行此操作之前,我保存了我的故事板。回想起来,我应该制作一份副本并diff
在之前和之后进行。
回答by user3344977
For me, it wasn't because of a Storyboard ID
or a Segue
. I was receiving this warning because I had not set the View Controller's Custom Class
.
对我来说,这不是因为 aStoryboard ID
或 a Segue
。我收到此警告是因为我没有设置View Controller's Custom Class
.
Select the View Controller
on the Storyboard
, then in the Utilities Pane
, select the Identity Inspector
icon. Under Custom Class
, see what value is inside of the Class
field.
选择View Controller
上的Storyboard
,然后在 中Utilities Pane
选择Identity Inspector
图标。在 下Custom Class
,查看Class
字段内的值。
If it just says UIViewController
, then you need to type in the class name. This will be the name of your .h
and .m
files that make up your custom UIViewController
subclass.
如果它只是说UIViewController
,那么你需要输入类名。这将是组成自定义子类的文件.h
和.m
文件的名称UIViewController
。