嵌入Segue - iOS 5 [英] Embed Segue - iOS 5

查看:65
本文介绍了嵌入Segue - iOS 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Container View拖到我的一个View Controllers上。这附带了一个嵌入式塞格。运行产生这个:

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'

所以从其他几个stackoverflow问题看来,这似乎没有在iOS 5中实现。但是,这些问题没有提出修复。 XCode不会让我使用任何其他类型的segue。

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.

如果答案是创建自定义容器视图,我将继续使用它。在过去的几天里,我见过很多代码。只是想知道是否有办法使用提供的Container View对象执行此操作。

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.

推荐答案

问题是Embed segue是iOS 6+。
它失败了,因为你试图实例化iOS 5中不存在的EmbedSegue内部类。显而易见的解决方案是,如果你需要iOS 5支持,不要使用EmbedSegue:)

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.

对于任何旧来说,解决方案都很明显-schooliOS开发人员。
以下是你如何做到的。

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


  1. 在你的父视图中,控制器在viewDidLoad中实例化子视图控制器:或者每当适合

  2. [self addChildViewController:childVC];

  3. [self.view addSubview:childVC.view];

  4. childVC.view.frame = ....;

  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 = ....;

现在您应该看到您在nib中为您的孩子VC所做的视图故事板将显示在您指定它的父视图中。

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 :)

干杯,

这篇关于嵌入Segue - iOS 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆