What did Loadview do when the app was launched?

Source: Internet
Author: User
What did Loadview do when the app was launched?

Check the official Apple documentation below:

1. When you access a Viewcontroller view property, if the value of the view is nil at this point, then Viewcontroller will automatically call the Loadview method. This method loads the nib file or creates an empty view object (Self.view = nil).


2. When creating a view using the nib file, it is not necessary to overload the Loadview method, because Loadview is the role of loading nib. If you want to reload, you must call [Super Loadview], otherwise the nib file will not be loaded.


3. When creating a view without nib, overloading this method (when nothing is written) defaults to creating an empty view object, which is Self.view = nil. At this point you must create a UIView object yourself, and then specify Self.view = MyView; But there's no need to call super because you don't need to create a view object in the Super method anyway. If you call super, it's a waste of resources.

4, in short, Loadview will only automatically load xib with the same name, or call the parent class method to create an empty view (nil black), and will not load the controller Viewcontroller from Storyboad.

What did Loadview do when the app was launched?

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.