views:

864

answers:

1

In the UISearchBar control, is the a way to change the Search key title for the keyboard to Done?

+7  A: 

For a searchbar named tablesearchbar:

// Set the return key and keyboard appearance of the search bar
        for (UIView *searchBarSubview in [tableSearchBar subviews]) {

            if ([searchBarSubview conformsToProtocol:@protocol(UITextInputTraits)]) {

                @try {

                    [(UITextField *)searchBarSubview setReturnKeyType:UIReturnKeyDone];
                    [(UITextField *)searchBarSubview setKeyboardAppearance:UIKeyboardAppearanceAlert];
                }
                @catch (NSException * e) {

                    // ignore exception
                }
            }
        }
Run Loop
It works. Fantastic answer. Many thanks.
Jim B
Thanks JK! Helped me as well
ambertch
Will this get past the App Store approval process?
zekel
As no private APIs are accessed, approval should not be withheld
Run Loop