无法从故事板显式加载视图控制器 [英] Unable to explicitly load view controller from storyboard

查看:100
本文介绍了无法从故事板显式加载视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从故事板明确加载视图控制器并拥有以下代码:

I'm loading a view controller from a story board explicitly and have this code:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
UIViewController *initViewController = [storyboard instantiateViewControllerWithIdentifier:@"InitialScreen"];

但是收到错误'Storyboard()不包含带有标识符'InitialScreen的视图控制器'

But am getting an error "'Storyboard () doesn't contain a view controller with identifier 'InitialScreen'"

然而从屏幕截图中可以看出,视图控制器确实具有该标识符。我在成功之前使用了这种相同的加载控制器的方式,但不知道为什么它不能正常工作。任何想法可能是什么问题?

Yet as can be seen from the screenshot, the view controller does have that identifier. I've used this identical way of loading controllers before successfully, but no idea why its not working this time. Any ideas what the issue could be?

推荐答案

我刚发现问题 - 这是模拟器的一个问题,我发现绝对没有错我的代码并且100%确定它没关系,当我过去处于那种情况时,我通常会发现罪魁祸首是Xcode本身。因此,即使我多次清理和重建,我决定尝试重置模拟器中的内容 - 并且它开始工作的宾果游戏。我把它归结为模拟器缓存内容中的错误,而不是更新以反映IB中所做的更改。

I've just found the problem - its an issue with the simulator, I could find absolutely nothing wrong with my code and was 100% sure it was ok, when I've been in that situation in the past I usually find the culprit is Xcode itself. So even though I'd cleaned and rebuilt multiple times I decided to try resetting the contents in the simulator - and bingo it started working. I put it down to a bug in the simulator caching content and not updating to reflect changes made in IB.

这篇关于无法从故事板显式加载视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆