Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to explicitly load view controller from storyboard

Tags:

ios

storyboard

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"];

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?

enter image description here

like image 422
Gruntcakes Avatar asked Apr 01 '13 23:04

Gruntcakes


1 Answers

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.

like image 156
Gruntcakes Avatar answered Oct 02 '22 05:10

Gruntcakes