Proficient in iOS development-note2

Source: Internet
Author: User

?? There are three basic modes of user interface controls: dynamic, static (non-dynamic), and passive

Dynamic: Things happen when you click on them-usually a time code that you write yourself.

Passive: Used only to store user-entered values for later use. These controls do not trigger any action methods, but users can interact with them and modify their values. such as: A text box on a Web page. Although you can verify your code when you leave the text box, the text box on the page is just the container where the data is stored. This data is submitted to the server when the user clicks the Submit button. The text box itself does not start out as any code, but when you click Submit, you can submit the data for the text box together.

Note: Although controls in iOS can trigger multiple action methods, in most cases it is best to implement unique actions for each particular purpose of the control. Although this feature is not normally used, it is important to be mindful when you re-associate an event with Interface Builder, to ensure that the previous association is broken before the new action method is associated.

View Properties

1.Mode

Lets you select how content is displayed inside the view.

Determines how the image is aligned within the view, and whether the image is scaled to fit the view size

2.Tag

Tag is used by developers, and the system never sets or modifies its value

Sets a numeric value that is used to help identify the same control, which is used to determine which control is passed to the action method through the sender parameter when the action method is called.

3.Interaction

check box

1) User Interaction Enabled, specifying whether to interact with the current object. You should select for most controls, or the action method cannot be triggered.

2) Multiple touch, determines whether the current control can accept multi-touch events.

4.Alpha

Defines the transparency of the image, which is the visibility of the content behind the image.

0.0 (fully transparent) ~1.0 (completely opaque)

Unless there is a good reason, the general setting is 1.0

5.Background

Used to determine the background color of a view

For an image view, this property only works if the image does not fill the entire view, or if some view of the image is partially transparent.

6.Tint

Some views are used when drawing themselves to specify the highlight color of the selected view

7.Drawing

check box

1) Opaque, default check, is used to tell iOS that there is no need to draw behind the current view, while allowing the iOS drawing method to accelerate the drawing of the current view with some optimizations

2) Hidden, check to hide an object

3) Clears Graphics Context, this basic does not need to be selected. If selected, iOS draws all areas covered by the object with transparent black before actually drawing the object. Due to performance issues, and there is little need for this, it is usually set to OFF (it may be selected by default).

4) Clip Subviews, if your view contains a sub-view, select it, only the sub-view portion that is within the bounds of the parent view will be drawn, and if unchecked, the child view will be fully drawn, whether or not the parent view boundary is exceeded.

If you do, you can enable it, but with performance in mind, this option is turned off by default.

5) AutoResize subviews, which tells iOS to automatically adjust the size of the child view when the size of the current view changes.

8.Stretching (Stretch)

Stretching is required only if you resize the rectangle view on the screen to cause the view to redraw.

Text Box Properties

1.Text

Control what the text box always displays

1) Plain text (Plain text)

2) attribute text (attributed text, can contain various fonts and different attributes)

2.Color

Set Font Color

3.Font

Used to set text size and various font properties

4.Alignment

Use to control the alignment of text in a text box

5.Placeholder

Placeholder, when the contents of the text box are empty, you can display a text box in gray text that tells the user what to enter in this field.

If there is not enough space, you can use placeholders instead of labels.

6.Background

7.Disabled

The above two fields are only used when you need to customize the appearance of a text box. In most cases, it is completely unnecessary and not recommended.

8.Border Style

Use to change how the border of a text box is drawn (default, the rightmost button is most commonly used)

9.Clear Button

Used to set the Clear button, which is a small X-type button that appears at the far right of the text box.

Often used in search boxes and other fields where you need to change content frequently, a text box that requires persistent data does not typically contain a clear button.

1) Clear when editing begins check box to specify whether users will erase existing text when they touch this field

10.Min Font Size

Set the minimum font size that text boxes can use when displaying text

1) The Adjust to fit check box allows you to specify whether the display text should vary with the size of the text box (checked by default)

11.Capitalization

Used to define the appearance and behavior of the keyboard when using this text box

If you select words, you can guarantee that each word you enter will automatically be converted into uppercase letters.

12.Correction Checksum

13.Spell checking spell checker

14.Keyboard type keyboard

15.Appearance appearance

Slightly

16.Return Key

This is a key at the bottom right of the virtual keyboard, and his changes will vary according to the user's ongoing operation. For example: Enter text in the search box to display search

Add a constraint to all views in the view controller by selecting the View controller in the document outline and clicking the Add Missing constrains menu option, Resolve Auto Layout issues, editor.

When you add constraints using the menu above, you need to check them carefully, and if they don't work as you expect, remove them and add the constraints manually.

?? Press the Done button to turn off the keyboard

1. Add code

VIEWCONTROLLER.M file

-(Ibaction) textfielddoneediting: (ID) sender

{

[Sender Resignfirstresponder];

}

2. In the connection Checker (select main.storyboard,command+6)

Connect the Do End on exit time to the yellow East (View controller) on top of the view controllers and select the Textfielddoneediting method

?? Touch the background to close the keyboard

1. Add code

VIEWCONTROLLER.M file

-(Ibaction) Backgroundtap: (ID) sender

{

[Self.namefield Resignfirstresponder];

[Self.numberfield Resignfirstresponder];

}

2. Select View in storyboard to change its underlying class from UIView to Uicontrol in command+3 (Identity checker)

3. Connect the touch down to the yellow East (view controller) at the top of the view controllers in the connection inspector and select the Backgroundtap method

Proficient in iOS development-note2

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.