<span id="Label3"></p><p><p>Viewcontroller is a view of the Controller,viewcontroller responsibilities mainly include the management of the internal view of the loading display and uninstall, while responsible for communication and coordination with other Viewcontroller.</p></p><p><p><span style="color: #3366ff;">There are two types of viewcontroller in Ios:</span></p></p><p><p><span style="color: #3366ff;">1. Display content</span> , such as uiviewcontroller,uitableviewcontroller, can also be customized to inherit from Uiviewcontroller Viewcontroller.</p></p><p><p><span style="color: #3366ff;">2. Viewcontroller for control and display of other viewcontroller. This viewcontroller is generally a viewcontroller container</span> : such as Uinavigationviewcontroller and uitabbarcontroller,</p></p><p><p><span style="color: #3366ff;">They all have a property: viewcontrollers. Uinavigationcontroller is to store and manage the Viewcontroller,uitabbarcontroller in the form of a stack that manages viewcontroller in the form of an array.</span></p></p><p><p></p></p><p><p>Viewcontroller life cycle</p></p><p><p>alloc, initwithnibname->loadview->viewdidload,</p></p><p><p></p></p><p><p>viewwillappear->viewdidappear, Viewwilldisappear</p></p><p><p></p></p><p><p>Viewdiddisappear->dealloc.</p></p><p><p>Launcher: Viewdidload [view is about to be displayed, at which point Superview is generally nil, i.e. the view has not been added to any view]</p></p><p><p>Viewwillappear [view already displayed, added to another view]</p></p><p><p>View did Appear [view is about to disappear, at which point half has not yet been called removefromsuperview]</p></p><p><p>Press the home button and there is no record (the program is Suspended)</p></p><p><p>Double-click the home key to remove the program: viewwilldisappear [view removed from superview]</p></p><p><p>View did disappear</p></p><p><p><span style="color: #3366ff;">When the view is added to another view, viewwillappear is called, and then the Viewdidappear is Called.</span></p></p><p><p><span style="color: #3366ff;">When a view is removed from another view, viewwilldisappear is called, and then the Viewdiddisappear is Called.</span></p></p><p><p>Viewwilldisappear and Viewdiddisappear are only called when there is insufficient memory or when the program is Terminated.</p></p><p><p></p></p><p><p>The difference between Loadview and Viewdidload is that when the view is loadview, the view has been generated, viewdidload, and the Loadview will only be called once, Viewdidload may be called multiple times (view may be loaded multiple times).</p></p><p><p>Code organization--"how to design a good viewcontroller</p></p><p><p>1. Do not appear in Init to create the view Code. There should be only initialization of the relevant data in Init (very important), do not drop self.view in init, otherwise it will cause Viewcontroller to create the VIEW. (because View is lazyinit).</p></p><p><p>2. Only the view is initialized in loadview, which is typically used to create navigationbar of the more critical view, such as the Tabview,uinavigationcontroller of Tableviewcontroller.</p></p><p><p>3. Viewdidload The view is now available, which is best for creating additional view and Controls. One thing to note is that Viewdidload is called multiple Times.</p></p><p><p>4. Viewwillappear This is typically called before the view is added to the Superview before the animation is Toggled. Here you can do some pre-display processing. For example, keyboard popup, some special process Animation.</p></p><p><p>5. Viewdidappear is generally used for post-display.</p></p><p><p>IOS Viewcontroller life cycle</p></p></span>
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