一、FirstViewController:
(1):viewWillAppear:
(2):viewDidAppear:
(3):viewWillDisappear:
(4):viewDidDisappear:
二、SecondViewController:
(5):viewWillAppear:
(6):viewDidAppear:
(7):viewWillDisappear:
(8):viewDidDisappear:
三、两控制器的切换:
A.切换方式一:【push】与【pop】
(a):FirstViewController首次显示时:
image.pngviewWillAppear: ----> viewDidAppear:
即(1)--->(2)
(b):FirstViewController ------【push】------> SecondViewController时:
push(3)--->(5)--->(4)--->(6)
解读:
FirstViewController 即将消失 ------>
SecondViewController即将出现 ------>
FirstViewController 彻底消失 ------>
SecondViewController彻底出现
(c):SecondViewController ------【pop】------> FirstViewController时:
pop(7)--->(1)--->(8)--->(2)
解读:
SecondViewController 即将消失 ------>
FirstViewController 即将出现 ------>
SecondViewController 彻底消失 ------>
FirstViewController 彻底出现
B.切换方式二:【present】与【dismiss】
(a):FirstViewController首次显示时:
image.pngviewWillAppear: ----> viewDidAppear:
即(1)--->(2)
(b):FirstViewController ------【present】------> SecondViewController时:
present(3)--->(5)--->(6)--->(4)
解读:
FirstViewController 即将消失 ------>
SecondViewController即将出现 ------>
SecondViewController彻底出现 ------>
FirstViewController 彻底消失
(c):SecondViewController ------【dismiss】------> FirstViewController时:
dismiss(7)--->(1)--->(2)--->(8)
解读:
SecondViewController 即将消失 ------>
FirstViewController 即将出现 ------>
FirstViewController 彻底出现 ------>
SecondViewController 彻底消失
总结:
【push/pop】与【present/dismiss】的区别:
(A)切换方向上
【push/pop】:默认界面左右切换;
【present/dismiss】:默认界面上下切换;
(B)方法执行顺序
【push/pop】:
push:(3)--->(5)--->(4)--->(6)
pop:(7)--->(1)--->(8)--->(2)
push与pop
【present/dismiss】:
present:(3)--->(5)--->(6)--->(4)
dismiss:(7)--->(1)--->(2)--->(8)
present与dismiss
网友评论