Working with the different keyboard styles

In this recipe we will learn how to delete an item from a table view, as well our core data model.

Getting Ready

Following on from our previous recipe, we will learn how to apply customized keyboard styles to fields within our UIAlertView as defined in our btnAdd method that we defined in an earlier recipe.

How to do it...

To begin, follow these simple steps as outlined in the following order:

  1. Open the BooksViewController.m implementation file from the Project Navigator window.
  2. Modify the btnAdd method to apply a custom keyboard type for our bookTitle field, as shown by the highlighted code section in the following code snippet.
       UIAlertView *alert = [[UIAlertView alloc] 
       initWithTitle:@"Add Book Details" message:@"
    
    
    
    " 
       delegate:self cancelButtonTitle:@"Cancel" 
       otherButtonTitles:@"OK", nil];
       bookTitle = [[UITextField alloc] 
       initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
       [bookTitle setPlaceholder:@"Book Title:"];
       [bookTitle setBackgroundColor:[UIColor whiteColor]];
       bookTitle.keyboardType = UIKeyboardTypeAlphabet;
       [alertaddSubview:bookTitle];

How it works...

In this recipe, we begin by updating the keyboardType property of the bookTitleUITextField control and then specify the UIKeyboardTypeAlphabet variable as the keyboard type to use.

There's more…

The keyboardType property accepts an enumeration type named UIKeyboardType.

The following table explains some of these types:

Keyboard type

Description

UIKeyboardTypeDefault

Default keyboard for the current input method.

UIKeyboardTypeASCIICapable

Displays standard ASCII characters.

UIKeyboardTypeNumbersAndPunctuation

Displays numbers and punctuation keyboard.

UIKeyboardTypeURL

Displays a keyboard optimized for URL entry.

UIKeyboardTypeNumberPad

Displays a numeric keypad designed for PIN entry.

UIKeyboardTypePhonePad

Displays a keypad designed for entering telephone numbers.

UIKeyboardTypeNamePhonePad

Displays a keypad designed for entering a person's name or phone number.

UIKeyboardTypeEmailAddress

Displays a keyboard optimized for specifying email addresses.

UIKeyboardTypeDecimalPad

Displays a keyboard with numbers and a decimal point.

UIKeyboardTypeTwitter

Displays a keyboard optimized for twitter text entry, with easy access to the @ and # characters.

UIKeyboardTypeAlphabet

This has been depreciated, but uses the keyboard that displays standard ASCII characters.

Note

For more information on the UIKeyboardType class, as well as the various keyboard types, refer to the Apple Developer Documentation located at: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html

See also

  • The Inserting data within our Core Data data model recipe
..................Content has been hidden....................

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