How to use view controller containment
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的更多相关文章
- 【IOS笔记】View Controller Basics
View Controller Basics 视图控制器基础 Apps running on iOS–based devices have a limited amount of screen s ...
- 组合View Controller时遇到的一点问题
View Controller的组合应用其实很常见了,比如说Tab bar controller和Navigation view controller的组合使用,像这种一般都是Navigation v ...
- 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 ...
- 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 ...
- iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(下)
这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...
- 报错: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 ...
- iOS架构师之路:控制器(View Controller)瘦身设计
前言 古老的MVC架构是容易被iOS开发者理解和接受的设计模式,但是由于iOS开发的项目功能越来越负责庞大,项目代码也随之不断壮大,MVC的模糊定义导致我们的业务开发工程师很容易把大量的代码写到视图控 ...
- View Controller Relationships
Parent-child relationshipsParent-child relationships are formed when using view controller container ...
- Model View Controller
On the iPhone or iPod touch, a modal view controller takes over the entire screen. This is the defau ...
随机推荐
- C++——函数模板和类模板
声明: //template 关键字告诉C++编译器 我要开始泛型了.你不要随便报错 //数据类型T 参数化数据类型 template <typename T> void myswap(T ...
- NX二次开发-更改图纸尺寸内容(编辑文本)uc5566
#include <uf.h> #include <uf_drf.h> #include <uf_obj.h> #include <uf_part.h> ...
- C语言中static用法介绍
C语言中static用法介绍 对于新手来说,很多东西的用法还不是很清楚,我们今天一起来看看C语言中static用法介绍 1.声明了static的变量称为静态变量,根据作用域的不同又分为 ...
- 尾插法-实现链表反转(有点bug,以后再来研究下)
def func2(head): p = head.next while p.next: q = p.next p.next = q.next # 重点 head.next = q q.next = ...
- css中的zoom的作用
1.检查页面的标签是否闭合不要小看这条,也许折腾了你两天都没有解决的 CSS BUG 问题, 却仅仅源于这里.毕竟页面的模板一般都是由开发来嵌套的,而 他们很容易犯此类问题.快捷提示:可以用 Drea ...
- Hadoop搭建,上传文件时出现错误,没有到主机的路由
解决方案:(1)从namenode主机ping其它slaves节点的主机名(注意是slaves节点的主机名),如果ping不通,原因可能是namenode节点的/etc/hosts 未配置主机名与IP ...
- POJ 2763 /// 基于边权的树链剖分
题目大意: 给定n个结点,有n-1条无向边,给定每条边的边权 两种操作,第一种:求任意两点之间路径的权值和,第二种:修改树上一点的权值. 因为是一棵树,可以直接把 u点和v点间(假设u为父节点,v为子 ...
- USACO 2011 February Silver Cow Line /// 康拓展开模板题 oj22713
题目大意: 输入n k,1-n的排列,k次操作 操作P:输入一个m 输出第m个排列 操作Q:输入一个排列 输出它是第几个排列 Sample Input 5 2P3Q1 2 5 3 4 Sample O ...
- mysql 06章_分组查询和链接查询
一.分组查询 在进行查询时,通常需要按某个或某些字段进行一些统计,因此就需要使用分组查询,但分组后通常需要与聚合函数使用,分组才有意义. 语法:SELECT <字段列表|*> FROM 表 ...
- 无法解析的外部符号 jpeg_std_error
1>dlib.lib(png_loader.obj) : error LNK2001: 无法解析的外部符号 png_set_sig_bytes 1>dlib.lib(png_loader. ...