NSLog

小说:全部梭哈是什么意思作者:成乙开文更新时间:2019-02-22字数:46766

“呵呵,八云的问题不难解决,我和你联手的话保证打造出一个和当年我爷爷一起并肩作战的鞍马一族的祖先一样威名远播的人。

大满贯:dmg3338.com

傍晚时分,李庆安终于抵达了长安,他没有在城外停留,命三千亲卫骑兵在城外驻扎,他本人则改乘一辆马车,在三百骑兵的护卫下直接向皇城而去。
这可着实将他给吓着了,自己这一掌怎么可能一点伤害都给对方造不成呢。

听得辎重大队驻地遭遇多股不明武装的袭击,鬼子旅团长急眼了,辎重大队是他的旅团后勤物资存储地,一旦被支那军袭击遭遇损失的话,那他的旅团将无法进行攻击浦口,看来这次对面的支那军部队是真得到了增援,开始向自己的阵地发起反击了。

NSLog


-(void)loadView;

  • loadView方法在UIVIewController的view被访问且为空的时候调用。
  • loadView方法不应该直接被调用,而是由系统调用。它会加载或创建一个View并把它赋值给UIViewController的view属性。
    以下代码会导致死循环
    ```
    -(void)loadView{
    NSLog(@"ViewController loadView");
    }

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"ViewController viewDidLoad");
    self.view.backgroundColor = [UIColor whiteColor];
    }
    ```

    - (void)viewDidLoad;

  • 当loadView将view加载完成,会调用viewDidLoad方法,该方法在UIVIewController初始化过程中只会执行一次,在该方法中可以进行页面相关的初始化。

    -(void)viewWillAppear:(BOOL)animated;

  • 页面将要出现时调用。页面每次即将出现时都会调用。
  • 当app有多级ViewController,pop操作后都会调用即将出现的ViewController的该方法,如果每次ViewController的出现都需要刷新页面,可在该方法中实现。

    -(void)viewWillLayoutSubviews;

  • ViewController的view即将对subviews进行布局。

    -(void)viewDidLayoutSubviews;

  • ViewController的view对subviews的布局完成。

    -(void)viewDidAppear:(BOOL)animated;

  • 页面已经出现时调用。页面每次出现时都会调用。
  • 在view被添加到视图层级中以及多视图,上下级视图切换时调用这个方法,在这里可以对正在显示的视图做进一步的设置。

    -(void)viewWillDisappear:(BOOL)animated;

  • 页面将要消失时调用。可能会被多次调用。
  • 页面之间push或者pop时都会调用。

    -(void)viewDidDisappear:(BOOL)animated;

  • 页面已经消失时调用。可能会被多次调用。
  • 页面之间push或者pop时都会调用。

    -(void)dealloc;

  • 页面被销毁时调用。
  • 该方法可以用来调试页面是否存在内存泄漏,如果存在,在页面出栈时将不会调用该方法。
  • 在该方法中可以处理需要手动释放的东西,比如观察者的移除。

    常用周期方法执行顺序

    由于我编码习惯是纯代码布局,所以对xib布局和storyboard布局的相关方法未加研究,代码如下

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"ViewController viewDidLoad");
    self.view.backgroundColor = [UIColor whiteColor];
    }

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"ViewController viewWillAppear");
}

-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"ViewController viewDidAppear");
}

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"ViewController viewWillDisappear");
}

-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"ViewController viewDidDisappear");
}

-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
NSLog(@"ViewController viewWillLayoutSubviews");
}

-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
NSLog(@"ViewController viewDidLayoutSubviews");
}

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

  • 打印结果:

ViewController viewDidLoad
ViewController viewWillAppear
ViewController viewWillLayoutSubviews
ViewController viewDidLayoutSubviews
ViewController viewDidAppear

以上只是显示一个页面的代码和打印结果,下面我们来看一下页面间的跳转时,生命周期执行的顺序。
从A页面调转到B页面,A页面代码:

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"A viewDidLoad");
    self.view.backgroundColor = [UIColor whiteColor];
    }

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"A viewWillAppear");
}

-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"A viewDidAppear");
}

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"A viewWillDisappear");
}

-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"A viewDidDisappear");
}

-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
NSLog(@"A viewWillLayoutSubviews");
}

-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
NSLog(@"A viewDidLayoutSubviews");
}

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

-(void)touchesBegan:(NSSet

B页面代码:

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"B viewDidLoad");
    self.view.backgroundColor = [UIColor whiteColor];
    }

-(void)dealloc{
NSLog(@"B dealloc");
}

-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"B viewWillAppear");
}

-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"B viewDidAppear");
}

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"B viewWillDisappear");
}

-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"B viewDidDisappear");
}

-(void)viewWillLayoutSubviews{
[super viewWillLayoutSubviews];
NSLog(@"B viewWillLayoutSubviews");
}

-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
NSLog(@"B viewDidLayoutSubviews");
}

  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

-(void)touchesBegan:(NSSet

}

从A页面跳转到B页面,再从B页面回到A页面,打印结果:

A viewDidLoad
A viewWillAppear
A viewWillLayoutSubviews
A viewDidLayoutSubviews
A viewDidAppear
************************跳转啦****************************
B viewDidLoad
A viewWillDisappear
B viewWillAppear
B viewWillLayoutSubviews
B viewDidLayoutSubviews
A viewDidDisappear
B viewDidAppear
************************回去啦****************************
B viewWillDisappear
A viewWillAppear
B viewDidDisappear
A viewDidAppear
B dealloc

当前文章:http://zxqss.com/48496.html

发布时间:2019-02-22 00:23:57

大富翁游戏棋系列 关于德扑圈伙牌 翼友棋牌作弊器 四川跑得快棋牌 快乐牛牛 养老院棋牌室都有什么 天天象棋下载最新版 天天斗地主免费斗地主

编辑:道公

我要说两句: (0人参与)

发布