Thursday, July 23, 2009

Positive Step Forward - iPhone Programming

Again, any programmers who read this don't need to laugh... but this was a significant step forward for me.

When you invoke a text or number field, the keyboard and number pads automatically appear and let you enter text. Included on that keyboard is a button labeled done.

I thought it was because I was pulling these pre-written elements from the Library that the keyboard never disappeared after I pressed done. So I was running this section, entering data, then switching to another screen and entering data....

Finally today I realized that besides releasing all the elements, all the views, all the memory steps - you also have to release the keyboard and interaction requests.

- (IBAction) textFieldDoneEditing: (id)sender
{
[sender resignFirstResponder];
}

is the code I was given to tell the keyboard (FirstResponder in previous command) to release control. This can also be invoked on numeric keypads and screens that do not include a "Done" button with "(IBAction)backgroundClick: (id)sender" being included in the header to define a giant button that includes all the background that can then be tapped just like the "Done" button.

This did not solve all my problems (by far) but it did allow me to enter text in two consecutive fields on the same data entry screen (whereas before I was having to manually step to the next field).

No comments:

Post a Comment