Search code examples
iphone-sdk-3.0uikituisearchbaruisearchdisplaycontroller

iPhone Text entry with completion and DONE button (not search)


Using iPhone SDK 3.0, I wish to allow text entry with (optional) completion options that appear as typing is occurring, i.e. also allowing freeformat entry. As such I am using a UISearchBar (which has the text change events) and a UISearchDisplayController to present options.

The problems is I want the DONE button to say DONE and not SEARCH, however I cannot find a way to set that. Clearly I feel I am missing something, or Interface Builder of the SDK API would have some property to set.

I have seen other apps (in the store) that have achieved the result I want (free format entry, completion, DONE button) so maybe there is an alternative approach I am missing. Thanks in advance for any pointers.


Solution

  • +1 For wal's answer, but to be on the safe side, and properly react to possible changes in the view hierarchy in further releases consider using this code:

    NSArray *subviews = [<searchBar> subviews] ;
    for(id subview in subviews) {
        if([subview isKindOfClass:[UITextField class]]) {
            [(UITextField*)subview setReturnKeyType:UIReturnKeyDone];
        }
    }