-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIViewController #279
Comments
Storyboard创建视图概念术语
基础手动关联
|
纯代码创建视图 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UIViewController
iPhone用户看到的App页面都是
UIViewController
。UIViewController
是管理UIKit
应用程序视图层次结构。在MVC设计模式扮演控制层的角色。
UIViewController
作为Controller主要职责有:UIView
)管理视图管理
每个ViewController管理一个视图层级(View Hierarchy)。
根视图(Root View)
根视图是管理视图层级的一个容器。
指定视图(View)
有三种方式指定视图:
storyboard和xib文件方式属于Interface Builder。
View生命周期
创建View的过程
(摘自iOS开发-UIViewController使用详解)
生命周期
摘自UIViewController Lifecycle
1. 创建阶段
init
initWithCoder
:Storyboard方式指定视图会调用这个initWithNibName
2. 加载
loadView
用于创建view
属性viewDidLoad
viewDidUnload
iOS6 已废弃注意:
3. 展示阶段
viewWillAppear
viewWillLayoutSubviews
viewDidLayoutSubviews
viewDidAppear
viewWillDisappear
viewDidDisappear
创建
UIViewController
基于三种指定视图的方式,创建
UIViewController
对应有三种方式:UIViewController *vc = [UIViewController alloc] init];
init
方法内部也会调用initWithNibName
。参考
UIViewController
Lifecycle - 分类UIViewController
生命周期-执行顺序The text was updated successfully, but these errors were encountered: