zoukankan      html  css  js  c++  java
  • UINavigationController管理view的方法

    1,在storyboard上删除预先建好的控制器,拖出NavigationController,使其rootView连接一个新建的ViewController(FKOneViewController),在FKOneViewController上放上一个button,点击button跳转到另一个新建的ViewController(FKSecondViewController)。

    2,在FKOneViewController和FKSecondViewController写入代码:

     1 #import "FKOneViewController.h"
     2 
     3 @implementation FKOneViewController
     4 - (void)loadView
     5 {
     6     [super loadView];
     7     NSLog(@"FKOneViewController---loadView");
     8 }
     9 
    10 - (void)viewDidLoad
    11 {
    12     [super viewDidLoad];
    13     NSLog(@"FKOneViewController---viewDidLoad");
    14 }
    15 
    16 - (void)viewWillAppear:(BOOL)animated
    17 {
    18     [super viewWillAppear:animated];
    19     NSLog(@"FKOneViewController---viewWillAppear");
    20 }
    21 
    22 - (void)viewDidAppear:(BOOL)animated
    23 {
    24     [super viewDidAppear:animated];
    25     NSLog(@"FKOneViewController---viewDidAppear");
    26 }
    27 
    28 - (void)viewWillDisappear:(BOOL)animated
    29 {
    30     [super viewWillDisappear:animated];
    31     NSLog(@"FKOneViewController---viewWillDisappear");
    32 }
    33 
    34 - (void)viewDidDisappear:(BOOL)animated
    35 {
    36     [super viewDidDisappear:animated];
    37     NSLog(@"FKOneViewController---viewDidDisappear");
    38 }
    39 
    40 - (void)dealloc
    41 {
    42     NSLog(@"FKOneViewController---dealloc");
    43 }
    44 @end
     1 #import "FKSecondViewController.h"
     2 
     3 @implementation FKSecondViewController
     4 - (void)loadView
     5 {
     6     [super loadView];
     7     
     8     NSLog(@"FKSecondViewController---loadView");
     9 }
    10 
    11 - (void)viewDidLoad
    12 {
    13     [super viewDidLoad];
    14     NSLog(@"FKSecondViewController---viewDidLoad");
    15 }
    16 
    17 - (void)viewWillAppear:(BOOL)animated
    18 {
    19     [super viewWillAppear:animated];
    20     NSLog(@"FKSecondViewController---viewWillAppear");
    21 }
    22 
    23 - (void)viewDidAppear:(BOOL)animated
    24 {
    25     [super viewDidAppear:animated];
    26     NSLog(@"FKSecondViewController---viewDidAppear");
    27 }
    28 
    29 - (void)viewWillDisappear:(BOOL)animated
    30 {
    31     [super viewWillDisappear:animated];
    32     NSLog(@"FKSecondViewController---viewWillDisappear");
    33 }
    34 
    35 - (void)viewDidDisappear:(BOOL)animated
    36 {
    37     [super viewDidDisappear:animated];
    38     NSLog(@"FKSecondViewController---viewDidDisappear");
    39 }
    40 
    41 - (void)dealloc
    42 {
    43     NSLog(@"FKSecondViewController---dealloc");
    44 }

    3,开始执行,观察打印信息

    3.1,程序启动完成时:

    2015-04-08 22:52:25.314 01-测试Navigation[735:30225] FKOneViewController---loadView

    2015-04-08 22:52:25.315 01-测试Navigation[735:30225] FKOneViewController---viewDidLoad

    2015-04-08 22:52:25.316 01-测试Navigation[735:30225] FKOneViewController---viewWillAppear

    2015-04-08 22:52:25.406 01-测试Navigation[735:30225] FKOneViewController---viewDidAppear

    3.2,点击button跳转时:

    2015-04-08 22:54:08.657 01-测试Navigation[735:30225] FKSecondViewController---loadView

    2015-04-08 22:54:08.657 01-测试Navigation[735:30225] FKSecondViewController---viewDidLoad

    2015-04-08 22:54:08.657 01-测试Navigation[735:30225] FKOneViewController---viewWillDisappear

    2015-04-08 22:54:08.658 01-测试Navigation[735:30225] FKSecondViewController---viewWillAppear

    2015-04-08 22:54:09.170 01-测试Navigation[735:30225] FKOneViewController---viewDidDisappear

    2015-04-08 22:54:09.171 01-测试Navigation[735:30225] FKSecondViewController---viewDidAppear

    3.3,点击返回箭头时:

    2015-04-08 22:55:38.856 01-测试Navigation[735:30225] FKSecondViewController---viewWillDisappear

    2015-04-08 22:55:38.856 01-测试Navigation[735:30225] FKOneViewController---viewWillAppear

    2015-04-08 22:55:39.361 01-测试Navigation[735:30225] FKSecondViewController---viewDidDisappear

    2015-04-08 22:55:39.361 01-测试Navigation[735:30225] FKOneViewController---viewDidAppear

    2015-04-08 22:55:39.361 01-测试Navigation[735:30225] FKSecondViewController---dealloc

    3.4,再次点击button时:

    2015-04-08 22:57:03.755 01-测试Navigation[735:30225] FKSecondViewController---loadView

    2015-04-08 22:57:03.756 01-测试Navigation[735:30225] FKSecondViewController---viewDidLoad

    2015-04-08 22:57:03.756 01-测试Navigation[735:30225] FKOneViewController---viewWillDisappear

    2015-04-08 22:57:03.756 01-测试Navigation[735:30225] FKSecondViewController---viewWillAppear

    2015-04-08 22:57:04.263 01-测试Navigation[735:30225] FKOneViewController---viewDidDisappear

    2015-04-08 22:57:04.264 01-测试Navigation[735:30225] FKSecondViewController---viewDidAppear

     

     

  • 相关阅读:
    linux网络配置
    第二章 以太网和数据封装
    linux用户权限
    第一章 网络互联
    linux学习之文件系统
    史上最全Java学习视频下载地址分享
    JAVA高级特性之集合
    Map集合不继承Collection接口,(HashMap类和TreeMap类)---输出结果,如果将Key值修改为首位不为0,HashMap输出就是随机顺序的,求指导,为什么为会这样???
    java中this关键字
    Java long数据类型---网上学习到的资料
  • 原文地址:https://www.cnblogs.com/fkunlam/p/4404902.html
Copyright © 2011-2022 走看看