导航栏、模态视图、controller的生命周期
2016-12-22 本文已影响0人
精神薇
CustomerViewController * cvc=[CustomerViewController new];
//self.window.rootViewController=cvc;
UINavigationController *nc=[[UINavigationController alloc] initWithRootViewController:cvc];
self.window.rootViewController=nc;
推出:
OneViewController *ovc = [OneViewController new];
[self.navigationController pushViewController:ovc animated:YES];
返回:
[self.navigationController popToRootViewControllerAnimated:YES];
模态视图:
显示
OneViewController * one=[OneViewController new];
one.modalTransitionStyle=UIModalTransitionStylePartialCurl;
[self presentViewController:one animated:YES completion:nil];
清除:
[self dismissViewControllerAnimated:YES completion:nil];
注意:
controller的生命周期:
load:只执行一次,初始化数据(loadview)
view:四个方法:
- (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
- (void)viewDidAppear:(BOOL)animated; // Called when the view has been fully transitioned onto the screen. Default does nothing
- (void)viewWillDisappear:(BOOL)animated; // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
- (void)viewDidDisappear:(BOOL)animated; // Called after the view was dismissed, covered or otherwise hidden. Default does nothing```