Reputation: 468
it is simple to set the Return key programmatically:
textField.returnKeyType = UIReturnKeyDone; // This is in the loadView/init-method
However, it seems that it is not so easy to toggle that key, i.e. change it from Done to something else depending on, for example, what is currently shown in the text field! That is, a subsequent statement in a callback method:
textField.returnKeyType = UIReturnKeyRoute;
does not change the keys title from Done to Route!?!?
Has anyone else observed this? Any workaround?
Regards,
/John
Upvotes: 0
Views: 1976
Reputation: 22767
If by "does not work" you mean it doesn't do anything perhaps you need something like this?
- (BOOL)textFieldShouldReturnUITextField *)theTextField
{
[theTextField resignFirstResponder];
return YES;
}
If by "does not work" you mean that the text is wrong, as far as I know you can only select from the set of predefined buttton types that the API provides. I don't know of any way to directly set that text. There may be a way with private apis (see EricaSadun.com)
Upvotes: 2