6

I used to have all my view controllers in the same storyboard, I decided that makes sense to split up the storyboards so I created a new storyboard file New File -> User Interface -> StoryBoard, cut all the controllers related with the user management (Login, register, password recover ...) and pasted them in the new file

Now when I call storyboard.instantiateViewControllerWithIdentifier("LoginViewController") it crashes with the following error:

'Storyboard (<UIStoryboard: 0x...>) doesn't contain a view 
            controller with identifier 'LoginViewController''

How can I solve that?

2
  • 1
    Did you instantiate the new storyboard? let storyboard2 = UIStoryboard(name: ..., bundle: ...) Commented Dec 8, 2014 at 11:46
  • That was the problem, thanks Commented Dec 8, 2014 at 12:09

2 Answers 2

16

I think your problem is here, navigate to the Main.storyBoard after that click on your viewController which you want to initiate after that give it to the identifier here:

enter image description here

May be this will help you.

Sign up to request clarification or add additional context in comments.

Comments

5

You have to create the new storyboard instance, and get the LoginViewController StoryboardId

//Here, create an instance of the second storyboard excluding the extension(.storyboard), 
var storyBoard = UIStoryboard(name: "SecondStoryBoard", bundle: nil) 

//Here instantiate view controller with the storyboard instance, 
//Before that create a storyboardId for the corresponding view controller.
var loginVC = storyBoard.instantiateViewControllerWithIdentifier("loginViewController") as LoginViewController

//Here, the storyboard identifier is "loginViewController" which is created in the respective view controller's "Identity" inspector

Hope this helps, Happy Coding :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.