美文网首页
导航栏、模态视图、controller的生命周期

导航栏、模态视图、controller的生命周期

作者: 精神薇 | 来源:发表于2016-12-22 20:49 被阅读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```

相关文章

网友评论

      本文标题:导航栏、模态视图、controller的生命周期

      本文链接:https://www.haomeiwen.com/subject/swuhvttx.html