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

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

问题描述

我已将一个容器视图拖到我的一个视图控制器上.这带有一个嵌入 Segue.运行会产生这样的结果:

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.

对于任何老派"的 iOS 开发人员来说,该解决方案似乎都很明显.以下是你的做法.

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

现在您应该在 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天全站免登陆