USING THE KEYBOARD

In iPhone programming, the views most commonly associated with the keyboard are the Text Field and the Text View. When a Text Field is tapped (or clicked, if you are using the Simulator), the keyboard is automatically displayed. The data that the user taps on the keyboard is then inserted into the Text Field. The following Try It Out demonstrates this.

TRY IT OUT: Using a Text Field for Inputs

image

  1. Using Xcode, create a new Single View Application (iPhone) project and name it Keyboardlnputs. You will also use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Select the KeyboardInputsViewController.xib file to edit it using Interface Builder.
  3. Populate the View window with the Label and Text Field views (see Figure 6-1). Set the Label to display the text “Alphanumeric Input.”
  4. Press Command-R in Xcode to run the application on the iPhone Simulator. When the application is loaded, the keyboard is initially hidden; and when the user clicks the Text Field, the keyboard automatically appears (see Figure 6-2).

    image

    FIGURE 6-1

    image

    FIGURE 6-2

How It Works

The beauty of the iPhone user interface is that when the system detects that the current active view is a Text Field, the keyboard automatically appears; you don't need to do anything to bring up the keyboard. Using the keyboard, you can enter alphanumeric data as well as numbers and special characters (such as symbols). The keyboard in the iPhone also supports characters of languages other than English, such as Chinese and Hebrew.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.148.137