Initwithcoder, awakefromnib, initwithframe

Source: Internet
Author: User

First, you can create a uiview object using the IB and encoding methods.

1. IB (interface builder) method: load a view from the NIB file. The initwithcoder method of the view object is called, and the awakefromnib method is called.

Cmbutton * button = [[[nsbundle mainbundle] loadnibnamed: @ "cmviewcontroller" Owner: Self options: Nil] lastobject]; // This statement calls the initwithcoder and awakefromnib methods of the button.

When "cmviewcontroller. Nib" is loaded for the first time, the initwithcoder and awakefromnib messages are sent to all objects in the NIB file, that is, the initwithcoder and awakefromnib methods of each object are called once.

2. encoding method. When you create a view object using code, the initwithframe method of the object is called.

Cmbutton * button = [[cmbutton alloc] init]; // The initwithframe method of the button is called.

 

Initwithcoder, awakefromnib, initwithframe

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.