The difference between IOS Loadview and Viewdidload

Source: Internet
Author: User

The difference between IOS development Loadview and Viewdidload

These two methods are essential to the development of the iphone. They can all be used to initialize some content when the view is loaded. But what difference do they have?

Viewdidload This method is called only when view is initialized from the nib file.

Loadview This method is called when the controller's view is nil. This method is used when creating a view programmatically. Such as:

    1. -(void) Loadview {
    2. UIView *view = [[UIView alloc] initwithframe:[uiscreen
    3. Mainscreen]. Applicationframe];
    4. [View Setbackgroundcolor:_color];
    5. Self.view = view;
    6. [View release];
    7. }

You implement the Loadview method in the controller, then you may be called by the memory management control at some point when the application is running. If the device is low on memory, the view controller receives a didreceivememorywarning message. The default implementation is to check whether the current controller's view is in use. If its view is not inside the view hierarchy currently in use and your controller implements the Loadview method, the view will be release and the Loadview method will be re-used to create a new view.

The difference between IOS Loadview and Viewdidload

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.