The Xib and storyboard principles in iOS, and the similarities and differences between Android interface layouts

Source: Internet
Author: User

Using text markup Language for layout, the most used should be the HTML language. HTML can be understood as an XML language with a special set of tags.


First, iOS Xib and storyboard display principle

There are 3 types of basic layout interfaces in iOS: code. Xib,storyboard.

1. Code

The Code layout interface is omnipotent. But it's usually very complicated. The layout of a simple interface may require very many lines of code. So it's very cumbersome.

Here is the code to create a button, with a minimum of 3 lines:

UIButton *btn = [UIButton buttonwithtype:uibuttontypecontactadd];    Btn.center = Cgpointmake (+);    [Self.view ADDSUBVIEW:BTN];

2. Xib

The xib is suitable for small-block interfaces and can be used as a single interface.

belongs to the drag-control type, only need to write the code loaded into Xib.

To open the result of the Xib file with a text editor:

Can see that the Xib essence is also an XML file.

The <document> tag is what xib to display.

Be able to see what is going to be displayed in the <view> tab. The Xib only shows a blank view with a color.

The principle of xib is to parse the XML file, find the corresponding view, and convert it into code. The object is then created and displayed.

Shaped like:

UIView *view = [[UIView alloc] init];    View.frame = CGRectMake (0.0, 0.0, 320, 480);

3.storyboard

Storyboard is suitable for big interface jump, etc., and the rich Viewcontroller makes the relief become very easy.

Same. Open the storyboard with a text editor and see for example the following:

It's essentially an XML file.

The <objects> tab is the interface you want to create.

Here Tabbarcontroller is used as the root view controller.

Tabbarcontroller point to 4 other view controllers.

The principle of storyboard is also to parse out the XML file, find the corresponding controller and so on. Converted into code. The object is then created and displayed.

same as the xib principle .


Second, the Android and iOS layout display comparison

Known. The layout of Android is basically complete with XML. Even if there is a so-called can drag the control of the place, can only be used to shape the rough.

The iOS package is pretty good, and if you don't open it with a text editor, a lot of people may not know that this is an XML file to display the layout.

on the Fundamentals : Android is the same as the basic layout of iOS, which separates the view from the model data. All follow the MVC design pattern.



Reprint Please specify source: http://blog.csdn.net/xn4545945

The Xib and storyboard principles in iOS, and the similarities and differences between Android interface layouts

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.