IPhone Text entry with end and DONE button (not search)
Using the iPhone SDK 3.0, I want to allow text input with (optional) completion parameters that appear as I type, i.e. also allows freeformat recording. So I use UISearchBar (which has text change events) and UISearchDisplayController to represent the options.
The problem is that I want the DONE button to say DONE and not SEARCH, however I can't find a way to set it. Obviously I feel like something is missing, or the Interface Builder API SDK will have some kind of property to install.
I have seen other apps (in the store) that achieve the result I want (free write, complete, DONE button), so maybe there is an alternative approach I am missing. Thanks in advance for any pointers.
source to share
+1 For wal's answer, but just to be safe and to react correctly to possible changes in the view hierarchy in future versions, consider using this code:
NSArray *subviews = [<searchBar> subviews] ;
for(id subview in subviews) {
if([subview isKindOfClass:[UITextField class]]) {
[(UITextField*)subview setReturnKeyType:UIReturnKeyDone];
}
}
source to share
Just needed to implement exactly this and couldn't find any great answers anywhere ... so I thought I'd give some insight. After going through the debugger and digging into the UISearchBar, it's pretty obvious. I just discovered a UITextView in the subviews of a uisearchbar and at this point you will need to set the return type on that UITextView as soon as you get a handle on it.
Psuedocode- UISearchBarObject.SubViewAtIndexOfUITextField.ReturnKeyType = UIReturnKeyType.Done
source to share
Odd, UISearchBar must support UITextInputTraits interface like UITextField and UITextView (it doesn't say what it does in the documentation) and therefore must have returnKeyType . I would try anyway.
If it doesn't, it is possible that one of the objects that the UISearchBar uses has this option.
source to share