IOS Xib using--add xib files to the controller

Source: Internet
Author: User

The Xib file is a lightweight file used to describe a local interface, similar to storyboard, and is edited using the interface Bulider tool. But storyboard is heavyweight, it is used to describe the entire software of the various interfaces, and can show multiple pages of the jump relationship. Before storyboard appeared, the interface was always represented using the Xib file. Of course, in addition to using the Xib file, you can directly use the code to generate the interface, either way, each has its own advantages and disadvantages.

Xib can be used to represent both the interface of a controller and a small interface that is local to different controllers. In this section, the main explanation is to use xib to represent a complete controller interface.

< a > What is a xib file

The Xib file is a file with a suffix of xib. Choose to use a template to create a new project, the project contains a launchscreen.xib file, which is the application's welcome interface, in which you can display pictures or text. However, this xib file is very special, it is just a simple interface, can not be associated with a class, it is not possible to set the display of Launchscreen.xib file content through code, because this welcome interface is displayed before the program starts.

< two > Create Xib file

Xib file creation is the choice of the user interface inside the empty template created, of course, if you want to create a new welcome interface, you can directly select the Launch screen template, in addition, storyboard file is also in this choice. When you select the empty template, the file suffix created by default is named Xib, which is the Xib file.

< three > controller automatically add xib file

When creating the controller, there will be an option, whether to choose to create a xib file at the same time, if checked on this option, will automatically generate three files, the header and source files of the class, as well as the Xib file, the view in the Xib file is the View property in the controller, therefore, The current Xib file is the controller's graphical interface, where adding controls and adding effects through code is the same.

< four > Controller manually add xib files

If you do not choose to create the Xib file at the same time when you create the controller, but instead create the Xib file separately, you need to follow the steps to associate it.

1, ensure that the name of the created Xib file is consistent with the name of the controller.

2. the created Xib file is an empty file that needs to be dragged from the IB in the lower right corner of a UIView control to the interface.

3. Click the file ' Owner ' in xib files and set it as the Controller class, which means that the current Xib file belongs to the current controller class.

4. Connect the View property in the controller with the view in Xib, because the current file's owner represents the controller, so it is using file's owner and view connection, there are many ways to connect.

After the connection is successful, you see the effect on the right side of the property.

Jerry Education
Source:http://www.cnblogs.com/jerehedu/
Copyright Notice: The copyright of this article is Yantai Jerry Education Technology Co., Ltd. and the blog Park is shared, welcome reprint, but without the consent of the author must retain this paragraph statement, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
Technical Consultation:

IOS Xib using--add xib files to the controller

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.