IOS uses code +xib to build UI interface instances

Source: Internet
Author: User

1. Background

Some of us can not just use code to build the interface, the code is omnipotent, you can implement the interface in other ways, with the code will certainly be able to

Implementation, but we do not need to do so, sometimes with xib will be a better choice, code and xib the pros and cons of the place we need to know, in order to

Taking into account the advantages of these two building interfaces, mixed use is a good choice. (I'm having this problem writing a static form in code.)

, I will not do this, so the implementation is also dynamic, I think it is not possible to achieve static, in this way to achieve the form to obtain data will be

A big problem: with the agent can be achieved, really in this way to do you will feel very troublesome, xib static table also has great convenience, because

For each control that can be accessed directly. )

2. Development environment

My development environment is Xcode 5.1.1,ios SDK 7.1

3. Two implementations

First, build the class file, and then build Xib

Sometimes there are problems in this way, so it's not recommended.

Steps:

1. Create a new class file

2. Create a new Xib file, preferably the same as the class file name

3. Two File Creation Association (note the place where the mark was marked)

1) Drag a view to the top. (The view cannot be Viewcontrol, this is the key Viewcontrol it is not done)

2) Association class file

3) Associated View. (Hold down CTRL and drag the dots next to the screen so that the associated lines are established)

4. Using Xib (reference header file), new

Firstviewcontroller *firstview = [[Firstviewcontroller alloc]initwithnibname:@ "First" bundle : nil];

Second, the construction of the file when the time to tick the new xib

Use directly after the new build.

4. Source code Download

SOURCE download

IOS uses code +xib to build UI interface instances

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.