https://www.hackingwithswift.com/example-code/uikit/how-to-use-view-controller-containment

private func add(asChildViewcontroller viewController: UIViewController){

// Add Child View Controller

addChild(viewController)

// Add Child View as Subview

view.addSubview(viewController.view)

// Configure Child View

viewController.view.frame = view.bounds

viewController.view.autoresizingMask = [.flexibleWidth,.flexibleHeight]

// Notify Child View Controller

viewController.didMove(toParent: self)

}

private func move(asChildViewcontroller viewController: UIViewController){

// Notify Child View Controller

viewController.willMove(toParent: self)

// Remove Child View From Superview

viewController.view.removeFromSuperview()

// Notify Child View Controller

viewController.didMove(toParent: self)

}

How to use view controller containment的更多相关文章

  1. 【IOS笔记】View Controller Basics

    View Controller Basics   视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...

  2. 组合View Controller时遇到的一点问题

    View Controller的组合应用其实很常见了,比如说Tab bar controller和Navigation view controller的组合使用,像这种一般都是Navigation v ...

  3. View Controller Programming Guide for iOS---(三)---Using View Controllers in Your App

    Using View Controllers in Your App Whether you are working with view controllers provided by iOS, or ...

  4. View Controller Programming Guide for iOS---(二)---View Controller Basics

    View Controller Basics Apps running on iOS–based devices have a limited amount of screen space for d ...

  5. iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(下)

    这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...

  6. 报错:Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?

    原因分析:在StoryBoard中没有一个view controller设置了Initial Scene. 解决方案:在Storyboard中,选择一个view conroller作为story bo ...

  7. iOS架构师之路:控制器(View Controller)瘦身设计

    前言 古老的MVC架构是容易被iOS开发者理解和接受的设计模式,但是由于iOS开发的项目功能越来越负责庞大,项目代码也随之不断壮大,MVC的模糊定义导致我们的业务开发工程师很容易把大量的代码写到视图控 ...

  8. View Controller Relationships

    Parent-child relationshipsParent-child relationships are formed when using view controller container ...

  9. Model View Controller

    On the iPhone or iPod touch, a modal view controller takes over the entire screen. This is the defau ...

随机推荐

  1. php上传(三)

    关于一些上传插件的运用 JQuery上传插件Uploadify使用详解 http://www.cnblogs.com/oec2003/archive/2010/01/06/1640027.html

  2. NX二次开发-UFUN获得图纸页数量UF_DRAW_ask_num_drawings

    #include <uf.h> #include <uf_draw.h> #include <uf_ui.h> UF_initialize(); //获得有多少张图 ...

  3. ZOJ3953-Intervals-贪心

    目录 Catalog Solution: (有任何问题欢迎留言或私聊 && 欢迎交流讨论哦 Catalog Problem:Portal传送门  原题目描述在最下面.  给你n个区间, ...

  4. org.mybatis总是认不出来的原因,pom.xml中有

    idea打开maven project,然后就华丽丽的看见下载失败,怎么刷新都没有用. 请按以下步骤完成即可: https://blog.csdn.net/ZhengYanFeng1989/artic ...

  5. (转)python基础之迭代器协议和生成器(一)

    一 递归和迭代 二 什么是迭代器协议 1.迭代器协议是指:对象必须提供一个next方法,执行该方法要么返回迭代中的下一项,要么就引起一个StopIteration异常,以终止迭代 (只能往后走不能往前 ...

  6. Zabbix监控RabbitMQ

    github下载开源脚本:https://github.com/jasonmcintosh/rabbitmq-zabbix 运行环境:python2.6.6 脚本分析: rabbitmq-zabbix ...

  7. scikit-learn 应用

    首先是sklearn的官网:http://scikit-learn.org/stable/ 在官网网址上可以看到很多的demo,下边这张是一张非常有用的流程图,在这个流程图中,可以根据数据集的特征,选 ...

  8. POJ1149_PIGS(网络流/EK)

    PIGS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 15721   Accepted: 7021 Description ...

  9. 唯一id

    package com.debug.kill.server.utils; /** * Created by Administrator on 2019/6/20. */ import org.apac ...

  10. Repeater 分页

    1.RepeaterDemo_Page.aspx前台代码 <body> <form id="form1" runat="server"> ...