Search VG Five
Categories & Tags

Entries in uisearchbar (1)

Thursday
23Apr2009

UISearchBar - Disabling autocorrection and capitalization

One of the most basic things you don't want when searching is for the search engine to correct your search on the fly. Google does a good job with asking you if you meant a similiar spelling or choice of words, but you still want to be sure that any search term you type is the one that gets sent in the first place.

On the iPhone, the autocorrection is turned on for all text entry fields by default. Here's how to turn both autocorrection and autocapitalization off:

UISearchBar.autocorrectionType = UITextAutocorrectionTypeNo;

UISearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;

You will want to replace UISearchBar with the name of your object.

This is the default behavior that I (and I assume most users) expect when they start typing into a search bar. Of course, some programs may benefit from autocorrection.