[Uiviewcontroller Addchildviewcontroller]

Source: Internet
Author: User

These new methods and properties are used to improve our way of programming. So let's take a look at some of the previous potential problems with the use of Uiviewcontroller and recognize the problem, so that we can understand the meaning of Apple's change.

In the past, a Uiviewcontroller view might have a lot of small sub-view. These sub-view are often covered at the end, and we add a lot of sub-view with Addsubview in the outermost Viewcontroller Viewdidload method. Most of these sub-view will not always be on the interface, only in some cases will appear, such as the login failed prompt view, upload attachment successful hint view, network failure prompt view and so on. But while these are rarely seen, we often keep them in memory. In addition, when a memory warning is received, we can only manually remove these view from Super view.

The new Apple API adds the Addchildviewcontroller method and wants us to call the [self Addchildviewcontroller:child] method while using Addsubview to set the sub The view corresponding Viewcontroller is also added to the current Viewcontroller management. For those who currently do not need to display the Subview, only through the Addchildviewcontroller Subviewcontroller add in. Call the TransitionFromViewController:toViewController:duration:options:animations:completion method when it needs to be displayed.

In addition, when the memory warning of the system is received, the system will automatically unload out the subview that are not currently displayed to save RAM.


[Uiviewcontroller Addchildviewcontroller]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.