1. In the APPDELEGATE.M:
2. In the SecondViewController.h:
3. In the FIRSTVIEWCONTROLLER.M:
4. In the SECONDVIEWCONTROLLER.M:
5. Finally, run the program and find the problem:Secondviewcontroller object is Firstviewcontroller object Navigationcontroller push,
The Secondviewcontroller object first invokes the execution of its-test method,-setwords: Method, Test2 method, Test3 method, in order,
Finally, the-viewdidload method of the Secondviewcontroller object is called to execute,
This leads to-setwords: _label.text = _words in the method, and becomes the [nil object settext:_words], which is equivalent to no execution, nature can not achieve the effect,
This is because the Uilabel object is only started in the-viewdidload method in the Secondviewcontroller object, so until then, _label is always an empty object (that is, the nil object)
6. Summary of issues:
b *b = [[B alloc] init];
[A.navigationcontroller pushviewcontroller:b Animated:yes];
[B methodinb];
Before iOS7, it is no problem to write this, call the process:
-loadview,-viewdidload,-viewwillappear,-viewdidappear, and finally-METHODINB
Since iOS7, the invocation process has changed:
[A.navigationcontroller pushviewcontroller:b Animated:yes];
The first call executed in B is-methodinb,-loadview,-viewdidload,-viewwillappear,-viewdidappear
7. Problem Solving:
since the-viewdidload method of the stack Ding Zi controller after push is executed by the last call, remove the-setwords: _label.text = _words in the method;
Instead, write _label.text = _words in the-viewdidload method, and you can assign it successfully!
Pushviewcontroller:animated: The problem