Xcode中的故事板参考,我们应该在哪里使用它? [英] Storyboard reference in Xcode, where should we use it?

查看:117
本文介绍了Xcode中的故事板参考,我们应该在哪里使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode7 beta 中有一个新控件名为 Storyboard Reference 。下面是它的图像。

There is one new control in Xcode7 beta named as Storyboard Reference. Below is its image.

它的描述为


为视图控制器提供占位符外部故事板。连接到此占位符的Segues将在运行时实例化引用的视图控制器。

Provides a placeholder for a view controller in an external storyboard. Segues connected to this placeholder will instantiate the referenced view controller at runtime.

所以问题是


  1. 我们应该在哪些情况下使用它?

  2. 这用于通过segue连接两个故事板的视图控制器吗?

  3. 这种方法是用来以编程方式替换另一个故事板的VC吗?

  4. 它是否适用于较旧的iOS版本(iOS 9之前)?

  1. In which situations should we use this?
  2. Is this used to connect two storyboard's view controllers via segue?
  3. Is this approach used to replace VC of another storyboard programatically?
  4. Will it work on older iOS version(before iOS 9)?


推荐答案

更新(2016年1月6日):我只想快速提及使用Storyboard引用是非常简单,它将帮助您以更加干净和可维护的方式使用Storyboard。 一个很好的用例就是例如带有多个标签的 UITabBarController 。只需为每个选项卡创建一个Storyboard,并在 Main.Storyboard 链接中使用Storyboard引用链接到那些单独的Storyboard。用法非常简单:在创建Storyboard引用之后只需要为要链接的单个Storyboard提供 filename ,并在该单个Storyboard中设置初始视图控制器。而已! :)

UPDATE (January 6, 2016): I just want to quickly mention that using Storyboard references is very simple and is going to help you use Storyboards in a much more clean and maintainable way. A good use case for it is e.g. a UITabBarController with multiple tabs. Just create one Storyboard for each tab and in your Main.Storyboard link to those individual Storyboards using Storyboard references. Usage is very straightforward: after creating a Storyboard reference you only need to give it the filename of the individual Storyboard that you want to link to and set the initial view controller within that individual Storyboard. That's it! :)

现在接下来是我给@ YogeshSuthar的问题的原始答案

What follows now is the original answer I gave to @YogeshSuthar's question.


  1. 这可以在您的应用中使用多个故事板的情况下使用。到目前为止,您必须以编程方式从其他故事板中实例化视图控制器,现在您可以使用此参考并在故事板中创建您的segue,就像使用来自同一故事板的视图控制器一样

  1. this can be used in cases where you are using multiple storyboards in your app. until now you'd have to instantiate view controllers from other storyboards programmatically, seems like now you can just use this reference and create your segue in the storyboards just like with view controllers from the same storyboard

是的,您将当前故事板中的一个视图控制器与另一个故事板中的另一个视图控制器连接起来,您可以在这两个视图控制器之间创建一个segue

yes, you connect one view controller from your current storyboard with another view controller from a different storyboard and you can create a segue between these two

是的,这可以用来替换以前用于以编程方式从其他故事板中实例化视图控制器的代码

yes, this can be used to replace the code that was formerly used to instantiate view controllers from other storyboards programmatically

[更新thx到@AlexBasson ]故事板参考可以部署到 iOS 8 OS X 10.10 watchOS 1

[UPDATE thx to @AlexBasson] Storyboard references can deployed to iOS 8, OS X 10.10 and watchOS 1.

这篇关于Xcode中的故事板参考,我们应该在哪里使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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