yanx730 / yanx730.github.io

Leox' A&i
GNU General Public License v2.0
0 stars 0 forks source link

UIViewController #56

Closed yanx730 closed 7 years ago

yanx730 commented 7 years ago

https://developer.apple.com/reference/uikit/uiviewcontroller

yanx730 commented 7 years ago

Overview

VC主要的负责:

Subclassing Notes

每个应用至少一个VC,使用和应用VC参考 View Controller Programming Guide for iOS

View Management

每一个VC都管理者一个view的hierarchy,rootview存在VC的view属性上。rootview的大小和位置由它的拥有者决定(父视图controller或app window)。被Window拥有的VC是应用rootcontroller,它的大小是填满窗口。

有如下几种方式为VC指定一个View

使用autolayout代码方式创建constraints 参考:Auto Layout Guide

Handling View-Related Notifications

image

Handling View Rotations

iOS8屏幕转动的接口已经不在推荐使用。旋转被看做VC视图的大小发生了变化。 使用viewWillTransition(to:with:) 在ioc6、7上应用支持屏幕旋转是定义在Info.plist。

Implementing a Container View Controller

Here are the essential methods you might need to call:

Memory Management

State Preservation and Restoration