-viewWillAppear:和 -viewDidAppear:区别
?-viewWillAppear:和 -viewDidAppear:区别在于will和did的区别! viewWillAppear是在视图出现之前调用,更新用于显示视图的信息,此时视图还没有appear。
viewDidAppear是在视图出现之后调用,用于更新视图显示出来后,一些动画之类的操作。 1)?ViewDidLoad?- Whenever I'm adding controls to a view that should appear together with the view,right away,I put it in the ViewDidLoad method. Basically this method is called whenever the view was loaded into memory. So for example,if my view is a form with 3 labels,I would add the labels here; the view will never exist without those forms. 2)?ViewWillAppear: I use ViewWillAppear usually just to update the data on the form. So,for the example above,I would use this to actually load the data from my domain into the form. Creation of UIViews is fairly expensive,and you should avoid as much as possible doing that on the ViewWillAppear method,becuase when this gets called,it means that the iPhone is already ready to show the UIView to the user,and anything heavy you do here will impact performance in a very visible manner (like animations being delayed,etc).If you override this method,you must call super at some point in your implementation. 3)?ViewDidAppear: Finally,I use the ViewDidAppear to start off new threads to things that would take a long time to execute,like for example doing a webservice call to get extra data for the form above.The good thing is that because the view already exists and is being displayed to the user,you can show a nice "Waiting" message to the user while you get the data. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- angularjs – angular-google-maps:找不到有效的中心属性?
- 【数据结构】求最小生成树的权值之和——Prim算法
- angular-material2 – 使用flex布局开发角度2材质的响应式布
- angular – 错误:模块’AppModule’声明的意外模块’DateP
- Shell运行/执行带参数的php脚本
- 全新的bbossgroups-1.0发布
- scala – 总结“大型”Nat’s
- 使Vim Curly Braces,Square Braces,Parens像Textmate一样
- 为什么我会像在ng-file-upload示例用法代码中那样在没有延迟
- Bootstrap 织梦搜索列表分页