IPhone development entry: Program Screen and control adjustment

Source: Internet
Author: User

Image structure

In CocoaTouch programming, an application can contain multiple pictures. 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 InterfaceBuilder, "ViewController" is the "File 'sowner" 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.

Widget Adjustment

Automatic Adjustment

Location Adjustment

When you use InterfaceBuilder to configure the control, 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> ShowFonts from the InterfaceBuilder menu 」. As shown in:

Select font and size

Adjust font and size

The text size cannot exceed the control size. Select Layout> SizeToFit to specify the font size of the control.

SizeToFit

Various controls

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

RoundRectButton

RoundRectButton is a normal button, but the four corners are rounded corners. Configured on View, and then you can enter text.

Configure RoundRectButton

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

RoundRectButton Action

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-ValueChanged

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

-(IBAction) myAction1 :( id) sender {

If ([senderisOn] = YES ){

...

// Processing when the switch control is ON

}

}

Slider

Slider Control Configuration

Slider control range settings

The Action of the Slider is "ValueChanged", 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 *) sendervalue] = 0.5f ){

...

// Processing when the Slider value is 0.5

}

}

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.