iOS ui--Small Instance project-add product and product name (using Xib file end) + Xib related knowledge points summary

Source: Internet
Author: User

Add items and product names small items (using the Xib file end version)

Tip: Blog At the end of the project source code in the Baidu cloud backup download link.

Xib Related Knowledge points summary 01-Basic Use

To start with Xib, if you want to use custom view code, you need to set the Xib class to that view type, and then I think it can be used directly, not really, but also need code to load the nib file, and finally return to the array object to use OH.

About xib see PPT Plus code can be used on custom controls

The process of loading a xib file

xib文件 -编译xib成功-> nib文件

The first way to load the nib file

NSArray* array  = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject]

The second way to load the nib file

UINib* nib = [UINib nibWithNibName:@"Test" bundle:[NSBundle mainBundle]];NSArray* array = [nib instantiateWithOwner:nil options:nil];

In the second way bundle: The following argument can be nil, if nil, the default is the value returned by the Mainbundle method that will load NSBundle.

The array object is returned because the control that is loaded xib can be multiple, so the default is to return an array object that stores these multiple controls

02-xib and Storyboard comparison:
    • Common:
      • is used to describe the software interface
      • are edited using the Interface Builder tool.
      • The essence is to convert the code to create the control
    • Different points
      • Xib is lightweight and is used to describe the local UI interface
      • Storyboard is a heavyweight, a multi-interface for describing the entire software, and the ability to show jump relationships between multiple interfaces
03-Drag lines to reference child controls

To summarize steps using Xib:

新建xib文件,设置好控件新建两个继承UIView的类,类名假设为MyUIView然后将xib文件的类型设置为MyUIView然后为MyUIView添加模型对象的属性,并为这个属性写好set方法托线,把xib的控件连接到MyUIView上,最好拖放在类扩展里。

If you have PPT, you can take notes directly.

Loading principle of 04-xib

Loading process of Xib

Loading the Xib file first parses the root node of the Xib file and creates the corresponding object through the class setting and then resolves the dimensions in the property dimension setting frame ... And so on. Settings for related properties ... A child control is encountered, the child control is also created, and the property is set, and finally is add to the parent control

For the Xib file, if the hierarchy relationship is:

    • UIView can be bound to a custom class file by setting class
      • The UILabel child control can also be bound to a custom class file by setting class
      • Uiimageview the entire composition control of the last Xib can be customized for each part
(Add goods and trade names) project backup Baidu Cloud Link: Http://pan.baidu.com/s/1pJDzpqF Password: rbsx

iOS ui--Small Instance project-add product and product name (using Xib file end) + Xib related knowledge points summary

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.