Interface Builder (referred to as IB, Interface Builder)

Source: Internet
Author: User


1.Interface Builder (for short, IB, Interface Builder)

What is 1.1?

A visual interface editing tool software, integrated into Xcode after XCODE4

1.2 Effects?

By visualizing the interface settings, you can complete the design of the interface without writing or writing code, thus reducing the amount of code written in the controller's viewdidload about creating controls and setting properties

1.3 Working principle

Save the settings for the desired control of the interface to the Xib file, when creating the controller instance, the system automatically creates an instance of each control in the view according to the specified xib file, sets the properties of the instance, and uses it in the initialization of the view that comes with the controller. Therefore, when you create a controller instance, you need to use the Initwithnibname method to specify which files are to be loaded for the configuration of the view

1.4 Required Documents

XxxxYyyy.h

Xxxxyyyy.m

Xxxxyyyy.xib (XML Interface Builder)

1.5 iboutlet,ibaction

Because the controls required in the view of the controller are automatically created by the system according to the Xib file, the view is already strong (strong reference) to these control objects, but at this point the controller cannot access the controls created by the system. A special method is required to obtain references to these objects created by the system.

If you add property access to an object in IB, making the control an externally accessible output port, make it the Iboutlet property that controls it by means of a wire.

If you are adding an event response to an object in IB, add the ibaction behavior to the control by wiring it

How to add a connection:

A. Open Split view, Xib file on left, xib controller m file on right

B. With the control selected, press the CTRL

C. Press the left mouse button on the control and drag to the right of the specified position

D. If you are adding an export, drag it into the extension

E. If you are adding an action, drag it to the implementation of the class

1.6 Parameters for action

When you add an event response for a control, you can add a parameter that defaults to the ID type, which is the control that is the source of the event, or who is the sender of the event.

When you need to use this parameter to distinguish between multiple controls connected to the same method, you can select the type parameter when you connect, set it to a specific type of control, and do not need to convert the type within the method.

1.7 Precautions when using the IB connection

If the control in the IB line, and then delete, then the deletion is only the code in the variables or methods, and does not delete the interface control record lines, must be in the Xib, check the control, right-click, see the binding lines there are a few, will not need to delete the connection, not error.

2. Base control (uistepper UISlider Uiswitch)

2.1 uistepper Step control

Important attributes:

. value

. maximumvalue

. MinimumValue

. stepvalue

Common events:

Value Changed event: triggered when the value is changed

2.2 UISlider Slider control

Important attributes:

. value

Important Events:

Value Changed event: triggered when the value is changed

2.3 Uiswitch Switch Control

Important attributes:

. On (BOOL) Gets or sets the state of the switch

. Enabled (BOOL) Gets or sets whether the control is available

Important Events:

ValueChanged Events

3.UITextField

What is 3.1?

is a single-line text input box that supports user input

3.2 Properties

. Text Gets or sets the text inside the text box

... ...

3.3 System pop-up keyboard

First Responder: When the user touches the interface, the system will be based on the location of the finger touch layer to the specific control, if the contact in the text box control area, then the text box is responsible for the touch event response, because the text box is more special, so the system automatically set the text box to respond to the first level of the event, and automatically eject the keyboard.

interrupted:

When the user taps the screen, the first thing to open is to find the Hit-view process. Starting with window, send hit-test messages to all the immediate sub-views until a control has no child view, and the contact is in this sub-view, the control is returned, so Hit-view finds the

When Hit-view is found, view becomes the first object to provide a response to the event, and if the object does not provide an event response, the event object will continue to pass to the parent view of the view, and if the parent view still does not provide a response, continue up. The event is discarded until it is passed to the UIApplication object and is still not processed. This process is called the responder chain.

3.4 How to turn off the keyboard

Method One: Let the keyboard give up the identity of the first responder

[Self.textfield Resignfirstresponder];

  

Method Two: Let the keyboard's parent view end the editing state

[Self.view Endediting.yes];

3.5 When do I close the keyboard? (Time to close the keyboard)

Time: Click the button in the lower right corner of the keyboard

Add an event to a text box

time machine two: tap the blank part of the screen

Overriding the controller's touchesbegan:withevent: method

4.UIAlertView &uiactionsheet

Homework:

1. The interface is as follows:

[Input box] [Send button]

1) When you click the Send button, a uilabel appears on the interface, which is the contents of the input box, which is required, the keyboard is closed, the input box is emptied.

2) When the user clicks the button in the lower right corner of the keyboard, the function and 1 are the same

3) The label itself is set to a width of 280, a height of 40, the distance to the left 20 points

4) More labels cannot overlap

2. The interface is as follows:

[Input Box Account]

[Input box Password]

[Login Button]

[UILabel Display the current status (login and display user name, no login display not logged in)]

1) After the user entered the user name and password, click Login, determine whether you can log in, if the login is successful, the label displays the current user's user name, if not logged in, show not logged in

2) When the user does not fill in the user name and password, click Login, provide user input user name and password

3) The first TextField supports next function and the second is done


--------------------------------------------------------------------------------------------------------

Summarize:

This article is from "IOS" blog, declined reprint!

Interface Builder (referred to as IB, Interface Builder)

Related Article

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.