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