The life cycle of IOS controls

Source: Internet
Author: User

The Viewcontroller life cycle includes:
Initialize
Viewdidload
Viewwillappear
Viewdidappear
Viewwilldisappear
Viewdiddisappear
Viewdidunload
Dispose

For application, each phase of the Viewcontroller corresponds to a method, and iOS calls the corresponding method at the appropriate time, so we can add the corresponding code to each method to do what we want to do. It should be noted that these methods are for Viewcontroller services, and for the Views object, there is no such method.
The life cycle method for view is as follows:

* viewdidload-called When to create the class and load from Xib. Great for initial setup and one-time-only work

* Viewwillappear-called right before your view appears, good for hiding/showing fields or any operations this you want T O happen every time before the view is visible. Because you might was going back and forth between views, this would be called every time your view was about to appear on th E screen

* viewdidappear-called after the view Appears-great place to start a animations or the loading of external data from An API.

* Viewwill/diddisappear-same idea as the willappear.

* Viewdidunload/dispose-available-to-you, in-objective-c, this is the Where do your cleanup and release of stuff, but t He is handled automatically so not much you really need to does here.

The application life cycle includes:
In iOS, the life cycle is made up of a series of methods, and for an app, the life cycle involved is:
1, click on the icon to start, the corresponding methods are:
Didfinishlaunchingwithoptions:
Applicationdidbecomeactive:
2, press the Home button, return to the desktop, the corresponding method:
Applicationwillresignactive
Applicationdidbecomeinactive
3, then click on the icon back to the foreground, corresponding method:
Applicationwillenterforegroud
Applicationdidbecomeactive
4, application suddenly be terminated, the corresponding method: 
     applicationwillterminate 
     Here you need to note that click the Home button 2, turn off the background program will not call this method, in Apple's iOS development Guide is described as follows: Span class= "Apple-converted-space" > 
even if you develop your application using IPhone SDK 4 and later, you must Still is prepared for your application to be terminated. If memory becomes constrained, the system might remove applications from memory on order to make more. If your application is currently suspended, the system removes your application from memory without any notice. However, if your application is currently running in the background, the system does call the Applicationwillterminate:met Hod of the application delegate. Your application cannot request additional background execution time from this method. "That is, when the machine is running out of memory, iOS will clean up the daemon, and at this time it will call the method, in general, rarely use this method, try not to write your application logic in this method.  

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.