IPhone development entry (8) --- Program Screen and control adjustment

Source: Internet
Author: User

Image structure

In Cocoa Touch programming, an application can contain multiple images. Display by selecting a list, or by using the label below, and so on. In CocoaTouch, one of these images becomes a View.

If you only create a View, you cannot implement a complete application. Here, you must generate Outlet and Action to connect the program to the View. For example, you can obtain information about the configuration control in the View and change its content. In this way, the program added to the View is called Controller. Or "ViewController" for the View 」. In Interface Builder, "ViewController" is the "File's Owner" used to create Outlet and Action 」.

 

Relationship between View and Controller

It can be seen that multiple views require multiple viewcontrollers. For simplicity, we first implement an image application.

Automatic control adjustment

 

Location Adjustment

When you configure the Control Using Interface Builder, a blue dotted line is displayed, as shown in. This is the best place to place. Using the functions provided by IDE, you can design a simple View.

Adjust the widget text size

Select the control you want to change, and select "Font"> "Show Fonts" from the Interface Builder menu 」. As shown in:

 

Select font and size

 

Adjust font and size

The text size cannot exceed the control size. Select Layout> Size To Fit To match the font Size of the widget.

 

Size To Fit

Various controls

This section describes some common controls. It is a control that causes Action through user operations.

Round Rect Button

The Round Rect Button is a normal Button, but the four corners are rounded corners. Configured on View, and then you can enter text.

 

Configure the Round Rect Button

When you select Action, "Touch Down" is the Action that occurs when the button is pressed.

 

Action of the Round Rect Button

Switch

A Switch is a Switch control. It has two statuses: On and off. Action is generated during each switchover.

 

Switch configuration

 

Initial status settings

 

Switch Action-Value Changed

For example, when the Outlet of the toggle control is [outlet isOn], its Action can be defined:

( IBAction) MyAction1 :( Id) Sender{
If([Sender isOn] = YES ){

...

// Processing when the switch control is ON

 
Slider

Slider Control Configuration

Slider control range settings

The Action of Slider is "Value Changed", that is, when the set Value changes, the corresponding Action will occur.

Action of the Slider Control

Through the Outlet of the Slider control, we can implement Action like the following code.

-(IBAction) myAction1 :( id) sender {
If ([(UISlider *) sender value] = 0.5f ){

...

// Processing when the Slider value is 0.5

}
}

Author: Yi Feiyang

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.