iOS ViewController入门

ViewController是App最基础的结构, 一个App由1到多个ViewController组成,
ViewController扮演MVC模式中的C(Controller), 展示并管理子视图树结构.
通过子类化UIViewController来实现实现自定义数据模型和视图之间的逻辑和通信

ViewController 分类

  • Content ViewController 直接管理内容子View显示
  • Container ViewController 以不同的方式管理和显示子ViewController

ViewController 展示和过渡

presenting view controller vs presented view controller

ViewController 显示

  • segue
  • showViewController:sender:
  • presentViewControllerAnimated:completion:

ViewController 关闭

presenting view controller中调用dismissViewControllerAnimated:completion:关闭一个presented view controller.

presented view controller返回数据用delegation模式, 参考UIImagePickerControllerUIImagePickerControllerDelegate