Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling Return key in iOS 8 keyboard extension

I'm working on an iOS 8 keyboard extension, and currently when the user taps on my Return key I'm running this code:

[self.textDocumentProxy insertText:@"\n"];

This works as expected in most places. However, in the Contacts app, if I edit a contact, select the first name field, and press Return, nothing happens. It does not move to the next field as expected. This is in contrast to the default keyboard, which does move to the next field.

Am I doing something wrong?

like image 718
Ben Williams Avatar asked Nov 11 '22 02:11

Ben Williams


1 Answers

Yes. Actually every textDocumentProxy will have it's UIReturnKeyType. Depending on which the method, used by your Return key should be changed.

   typedef NS_ENUM(NSInteger, UIReturnKeyType) {
    UIReturnKeyDefault,
    UIReturnKeyGo,
    UIReturnKeyGoogle,
    UIReturnKeyJoin,
    UIReturnKeyNext,
    UIReturnKeyRoute,
    UIReturnKeySearch,
    UIReturnKeySend,
    UIReturnKeyYahoo,
    UIReturnKeyDone,
    UIReturnKeyEmergencyCall,
   };

In your case, please implement jump to the next responder if you see that current self.textDocumentProxy.returnKeyType returns UIReturnKeyNext

like image 143
DmitryoN Avatar answered Nov 14 '22 22:11

DmitryoN