Differences between iPhone loadview and viewdidload

Source: Internet
Author: User

Loadview and viewdidload are two methods that must be used in iPhone development. They can be used to initialize some content during view loading. But what are their differences?

The viewdidload method is called only when the view is initialized from the NIB file. Viewdidload is used for initialization and loading.

The loadview method is called when the Controller's view is nil. This method is used to create a view programmatically. Loadview is the method called when the view is first loaded when code is used to generate the view. Use (write) code to implement controls. Functions used to generate controls using code. For example:

-(Void) loadview {uiview * view = [[uiview alloc] initwithframe: [uiscreen mainscreen]. applicationframe]; [view setbackgroundcolor: _ color]; self. view = view; [view release];}


If you implement the loadview method in the controller, you may be called by the memory management control at some time when the application is running. If the device memory is insufficient, View
The Controller receives a message from didreceivememorywarning. The default implementation is to check whether the current controller's view is in use. If its view
The view hierarchy is not currently in use, and your controller implements the loadview method, the view will be release,
The loadview method is called again to create a new view.

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.