什么时候实际调用viewDidLoad / viewDidAppear? [英] When is viewDidLoad / viewDidAppear actually called?

查看:175
本文介绍了什么时候实际调用viewDidLoad / viewDidAppear?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直认为只要你的视图出现在屏幕上就会调用 viewDidAppear ,但我被告知,例如,当你背景应用时(通过按主页按钮),然后将其重新启动, viewDidAppear 未被调用(转到后台不从视图层次结构中删除当前视图)。那么,对于出现的观点,它实际上意味着什么?此外,对于加载视图意味着什么,即。它何时实际发生(例如,当通过触摸应用程序图标等打开应用程序时)

I always thought that viewDidAppear was called whenever your view appeared on the screen, but I've been told that, for example, when you background an app (by pressing home button) and then bring it back up, viewDidAppear is not called (going to background "doesn't remove the current view from the view hierarchy"). So, what does it actually mean for a view to "appear"? Also, what does it mean for a view to "load", ie. when does it actually happen (for example, when the app is opened by touching the app icon, etc.)

推荐答案

是Heirarchy这个: - Alwys Whenevr你的视图控制器运行它像这样

Is Heirarchy Of this:- Alwys Whenevr Your View Controller Runs It Go Like This

第一个ViewDidLoad

1st ViewDidLoad

2nd ViewAppear

2nd ViewAppear

3rd ViewDidAppear

3rd ViewDidAppear

4th ViewWillDisAppear

4th ViewWillDisAppear

5th ViewDidDisAppear

5th ViewDidDisAppear

最后6个ViewDidUnload

Last 6th ViewDidUnload

你可以通过这个简单的生活来理解这一点示例: -

假设您在咖啡馆并且

第一 ==>您订购咖啡然后在此服务致电然后他们填写您的咖啡注意加载或填充所有包含像杯子上的咖啡被称为 ViewDidLoad

1st==> You Ordered Coffee Then Service Here Your Call Then They Fill Your Coffee On The Cup (Note Loading Or Filling All Contain Like Coffee on Cup Is Called ViewDidLoad )

<强>第二 == >>和服务时咖啡在您的桌面上(注意被称为 ViewWillAppear 您的咖啡就像您的ViewController 查看

2nd==>> And When Service Put Coffee On Your Table (Note Is Called ViewWillAppear Where Your Coffee just Like Your ViewController View )

第3次 == >>当您看到 Coffe 时(注意被称为 ViewDidAppear 您的视图可以在屏幕上看到,就像您看到咖啡一样)

3rd==>> And When You See Your Coffe (Note Is Called ViewDidAppear Where Your View Can See On Your Screen Just Like When Your See Your Coffee )

第4次 == >>之后当您已完成您的 Macachino咖啡并且为空时(注意被称为 ViewWillDisAppear 卸货或处理空的地方为立场对于ViewWillDisAppear)

4th==>> After That When You Finished Your Macachino Coffee And is Empty (Note is Called ViewWillDisAppear Where Unloading or Proccess Of Empty is Stands For ViewWillDisAppear )

5&第6次 == >>之后当服务到来时它会拿起你的咖啡并从你身边消失当你的眼睛消失(注意被称为 ViewDidDisAppear 当视图或你的屏幕像你的杯子一样空白时)最后所有过程都在这里完成....

5th & 6th==>> And After That When Service Came And It's Pick Up Your Coffee Cup And Take Back From You When Is Did Disappear From Your Eyes (Note is Called ViewDidDisAppear When View or Your Screen Is Go Blank Just Like Your Cup ) And Finally All Proccesss Done Here....

如果你再次订购了Diff。咖啡Aur相同咖啡,所有步骤再次调用相同,你有多个ViewController,他们再次呼叫A - B - A - B

And If You Again ordered Diff. Coffee Aur Same Coffee That All Step Called Again Same Like That, You Have Multiple ViewController And They Call Again Again A--B--A--B

Thx上市这个故事快乐编码

Thx For Listing This Story Happy Coding

这篇关于什么时候实际调用viewDidLoad / viewDidAppear?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆