Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 747
OdieO Avatar asked Jan 21 '13 03:01

OdieO


People also ask

How do I add segue to iOS?

To create a segue from the controller Control-drag from the View Controller icon to the Exit icon. Give this new segue the identifier unwind to reference it from the code.

What is embed segue?

Embed Segues are used by container views. These are views inside a viewController which loads another view from another viewController. If what you want is to present or push a view controller, you don't have to use an Embed segue.


1 Answers

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

like image 168
Dannie P Avatar answered Sep 28 '22 05:09

Dannie P