Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STORYBOARD EXCEPTION - Storyboard doesn't contain a view controller with identifier

I am currently developing an iOS application for both iPhone and iPad. I'm trying to show a NavigationController to make a module that shows files. In an iPhone it works just fine, but I can´t get it to work in iPad.

I'm getting the following error:

'Storyboard (<UIStoryboard: 0x919b200>) doesn't contain a view controller with identifier 'FilesNavigation''

and this is the code:

case 10: // Files
{
  UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"FilesNavigation"];

  FilesViewController *filesViewController = [storyboard instantiateViewControllerWithIdentifier:@"Files"];

  [navigationController pushViewController:filesViewController animated:YES];

  self.slidingViewController.topViewController = navigationController;

  break;
}

And in my storyboard I have already set the Storyboard ID for the navigation controller.

>##Custom Class 
>Class: UINavigationController
>##Identity
>Storyboard ID: FilesNavigation

I used this code for another case on the switch/case block for other module and it works for iPad too, its the first time that I have this error.

like image 379
origds Avatar asked Aug 21 '14 19:08

origds


People also ask

How do I set the identifier for view controller in storyboard?

In the Storyboard, select the view controller that you want to instantiate in code. Make sure the yellow circle is highlighted, and click on the Identity Inspector. Set the custom class as well as the field called "Storyboard ID". You can use the class name as the Storyboard ID.

What is UIStoryboard?

A UIStoryboard object manages archived versions of your app's view controllers. At design time, you configure the content of your view controllers visually, and Xcode saves the data needed to recreate that interface in a storyboard file in your app's bundle.

What is Navigation Controller in Xcode?

June 03, 2019. A navigation controller is responsible for managing the navigation of hierarchical content. The navigation controller manages the current displayed screens using the navigation stack. At the bottom of this stack is the root view controller and at the top is the view controller currently displayed.


2 Answers

I figured it out, the problem was that the Storyboard wasn't updating in the device.

  1. Uninstall the app from the simulator/iPhone/iPad
  2. Product > Clean
  3. Build & Run

As stated in @T0m_Twt's answer in this question

like image 73
origds Avatar answered Oct 12 '22 01:10

origds


In the right pane, in the identity inspector section give a storyboard Id to your Navigation Controller.

I took a screenshot for you

enter image description here

like image 32
meda Avatar answered Oct 12 '22 02:10

meda