Several functions of the iOS Development View controller when loading and unloading

Source: Internet
Author: User

1.-(void) Loadview

You should never call this function directly. The function will be called when the View controller's Views property is requested but its value is nil. The function loads or creates a view and assigns it to the View property.

If the view controller has a nib file associated with it, this method loads the view from the nib file. When the value of the Nibname property of the view controller is not nil, it indicates that the view controller has a nib file associated with it. If you use the Initwithnibname:bundle: function to assign a nib file to the view controller or if the iOS discovery application has a nib file named after the class name of the view controller, the view will be created by loading the nib file. If the view controller does not have a nib file associated with it, this method will create a blank UIView object instead.

If you use Interface Builder to create your view and initialize the view controller with it, you must not override this method.

In order to create your view manually, you can override this method. If you choose to do this, assign the root view of your view hierarchy to the View property. The view you create should be a standalone view and should not be shared with other view controller objects. Your implementation of this method's customizations should not call super.

2.-(void) viewdidload

The method is called when the View controller has loaded its view hierarchy into memory. This method will be called regardless of whether the view hierarchy is loaded through the nib file or the Loadview method becomes the implementation. You generally implement this method to complete additional initialization of the view loaded from the nib file.

3.-(void) viewdidunload

When memory is low and the views of the current view controller are not needed, the system selectively removes those views from memory. This method is called after the View controller's view is release and lets you do the final cleanup. If your view controller stores a separate reference to a view or its sub-views (if your view controller stores separate references to the view or its subviews). You should use this method to release these references. You can also use this method to remove any references that you create to support the view but not the objects you want. You should not use this method to release user data or any other information that is not easily recreated.

4.-(void) viewwillunload

When memory is low and the views of the current view controller are not needed, the system selectively removes those views from memory. This method is called before the View controller's view is release, so you do any cleanup before the view is deallocated. For example, you can use this method to remove the notifications received by the view and reestablish them when the view reloads.

Several functions of the iOS Development View controller when loading and unloading

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.