IOS Interface Builder: Load another. xib file in the. xib file

Source: Internet
Author: User

In development, a module that needs to be reused is often used, such as the display of each user in a buddy list or each dynamic, which is the same template, so that we can extract this part and put it in a separate. Xib. So how does the extracted. Xib work in other. Xib?

Now let's talk about how to load other. xib. Xib in. The approximate structure is this:

Create the project, the project name is called Compositexib

The creation of Mainview and Childview,childview will be included as child view into Mainview.

This is done after the creation:

Set the size of the Childview to be customizable, removing the status bar:

set Size:

Add a control: A ImageView, a label, and a button, and after adding it, your view should look like this:

Add the childview.xib corresponding cocoa class file:

. m add Setup Method:

. H Add View property:

Connect this cocoa class and childview.xib:

In this way, a child view is ready.

In Main. Xib Add a View control and set its class to the Childview that is prepared for the top:

Run:

IOS Interface Builder: Load another. xib file in the. xib file

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.