标签:占用 因此 一点 == 增加 加载 releases .com 忘记
// 实例化视图控制器
UiViewController *viewController = [[UiViewController alloc] init];
// 设置 window 的根视图控制器
self.window.rootViewController = viewController;
// 设置 viewController 的背景颜色
self.view.backgroundColor = [UIColor redColor];
// 向 viewController 上添加视图
[self.view addSubview:button];
// 向 viewController 上添加视图控制器
[self addChildViewController: viewController2];
[self.view addSubview:viewController2.view]
// 跳转到 指定 页面
[self presentViewController:viewController1 animated:YES completion:nil];
// 返回到 上一个 页面
[self dismissViewControllerAnimated:YES completion:nil];
- (void)loadView;
- (void)awakeFromNib;
- (void)viewDidLoad;
- (void)viewWillAppear:(BOOL)animated;
- (void)viewWillLayoutSubviews;
- (void)viewWillDisappear:(BOOL)animated;
// 纯代码加载视图
- (void)loadView {
[super loadView];
}
// 从 Nib 加载视图
- (void)awakeFromNib {
[super awakeFromNib];
}
// 视图已经加载
- (void)viewDidLoad {
[super viewDidLoad];
}
// 视图将要出现,在 viewDidLoad 执行完成之后执行
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
// 将要布局子视图
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
}
// 已经布局子视图
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
}
// 视图已经出现
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
// 视图将要消失
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
// 视图已经消失,不是销毁
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
// 更新视图控制器中视图的布局约束
- (void)updateViewConstraints {
// 在这里为你的 view 添加约束
[super updateViewConstraints];
}
// 更新视图布局约束
- (void)updateConstraints {
// 在这里为你的 view 添加约束
[super updateConstraints];
}
@interface MyViewController : UIViewController {
NSArray *dataArray;
}
@property (nonatomic, strong) IBOutlet UITableView *tableView;
@end
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Relinquish ownership any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
// For example: self.myOutlet = nil;
self.tableView = nil;
dataArray = nil;
[super viewDidUnload];
}
@property (nonatomic, weak) IBOutlet UITableView *tableView;
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
dataArray = nil;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
if (self.isViewLoaded && self.view.window == nil) {
self.view = nil;
}
dataArray = nil;
}
标签:占用 因此 一点 == 增加 加载 releases .com 忘记
原文地址:https://www.cnblogs.com/CH520/p/9413487.html