相当于iOS中的Fragment(Android) [英] Equivalent of Fragment (Android) in iOS

查看:165
本文介绍了相当于iOS中的Fragment(Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以在视图控制器中使用某些视图控制器,该控制器提供与Android中的 Fragment 相同的功能?我想使用自定义视图控制器,所以不想使用 NSTabViewController UISplitViewController

I want to know if there is a way to use some view controllers within a view controller which provides the same functionality as Fragments in Android? I want to use custom view controllers so I do not want to use NSTabViewController, UISplitViewController etc.

推荐答案

容器视图控制器允许在另一个视图控制器中包含子视图控制器.通过点击查看 docs 类概述中的更多..."链接.

Container View Controllers allow to include child view controller inside another view controller. Take a look at the docs by clicking on the "more..." link in the class overview.

实现容器视图控制器
自定义UIViewController子类还可以充当容器视图控制器.容器视图控制器管理其拥有的其他视图控制器(也称为其子视图控制器)的内容表示.孩子的视图可以按原样显示,也可以与容器视图控制器拥有的视图结合显示....

Implementing a Container View Controller
A custom UIViewController subclass can also act as a container view controller. A container view controller manages the presentation of content of other view controllers it owns, also known as its child view controllers. A child's view can be presented as-is or in conjunction with views owned by the container view controller....

在情节提要中使用它们就像将容器视图"拖动到视图控制器一样简单.

Using them in storyboards is as simple as dragging the Container View to your view controller.

Xcode会自动向其添加一个子视图控制器

And Xcode will automatically add a child view controller to it

这篇关于相当于iOS中的Fragment(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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