Search code examples
xcodeios5uistoryboardsegue

Embed Segue - iOS 5


I've dragged a Container View onto one of my View Controllers. This comes with an Embed Segue. Running produces this:

'Could not instantiate class named UIStoryboardEmbedSegueTemplate'

So from a couple other stackoverflow questions it seems this isn't implemented in iOS 5. However, the questions didn't suggest the fix. XCode won't let me use any other kind of segue.

If the answer is to create a custom Container View I'll go with that. I've seen plenty of code for that in the past couple days. Just wondering if there was a way to do this using the provided Container View object.


Solution

  • The problem is that Embed segue is iOS 6+. It fails because you are trying to instantiate EmbedSegue internal class which does not exist in iOS 5. The obvious solution is not to use EmbedSegue if you need iOS 5 support :)

    Here comes another question - what to use instead? I'm having the very same problem at the moment; I will share if I find any graceful architecture solution for that.


    looks like the solution is quite obvious for any "old-school" iOS developer. Here's how you do that.

    1. In your "parent" view controller instantiate "child" view controller in viewDidLoad: or whenever suitable
    2. [self addChildViewController:childVC];
    3. [self.view addSubview:childVC.view];
    4. childVC.view.frame = ....;

    Now you should see view you did for your child VC in nib or storyboard will display in your parent's view where you specify it.

    Hopefully this will help any seeking soul to decouple their logic :)

    Cheers, Dan