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]