Is there a way to add a cancel button to the keyboard displayed for UITextField
? Looking over the UITextInputTraits
Protocol Reference, I could not
Andrew, how's it going? it's Dima R!
As far as I know, there is no great way to do what you're trying to do. You can easily pick from one of the built in types that are listed here
typedef enum {
UIReturnKeyDefault,
UIReturnKeyGo,
UIReturnKeyGoogle,
UIReturnKeyJoin,
UIReturnKeyNext,
UIReturnKeyRoute,
UIReturnKeySearch,
UIReturnKeySend,
UIReturnKeyYahoo,
UIReturnKeyDone,
UIReturnKeyEmergencyCall,
} UIReturnKeyType;
What you could do is either add a view on top of the keyboard that contains your cancel button, or try to traverse through the view hierarchy and overlay what you want on the button that way (although this method is unreliable). Unfortunately, this is one thing Apple has not provided much customization for yet.
edit: Actually I think I misread your question from the start, since you wouldn't want a cancel button as the main return button anyways. In this case, the input accessory view is definitely the way to go.