Keyboards

When Steve Jobs introduced the iPhone in one of his most anticipated keynote speeches, he expressed a vision for a device that could successfully redefine the user's experience as she saw fit—not just the buttons on an application, but the ability to create an entirely new interface based on the specific needs of an application. Jobs's hatred for physical buttons must have included physical keyboards because Apple has found a use for 10 different "virtual" keyboard styles on the iPhone, and has provided an elegant interface to define them based on what kind of input is needed.

The keyboard object is derived from the UIView class, so it can be attached to just about any view object. An application can take full advantage of the different keyboards and keyboard styles available, change options such as autocorrection, and even customize the kind of buttons used.

Creating the Keyboard

The UIKeyboard class provides an easy interface to the keyboard without needing to worry about intercepting mouse events or dealing with any of the low-level details that plague other development platforms.

The UIKeyboard object has an understandably significant pixel size, and needs to be displayed in a large controlling view, such as a main view or preferences screen. The keyboard itself is 320×235 pixels.

The following example creates a 320×235 frame. The frame's origin begins at y-axis value 245 to fill the bottom portion of the screen.

CGRect kbRect; kbRect.origin.x = 0; kbRect.origin.y = ...

Get iPhone Open Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.