Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending images with iOS 8 custom keyboard?

I've been developing a custom keyboard for iOS 8, but stumbled upon a problem trying to send images using the keyboard. I did some research and it seems like there isn't a simple way to do this with UITextDocumentProxy because only NSStrings are allowed.

Am I either overlooking any simple ways to use a custom keyboard to send images and/or is there any way to work around this issue?

Thanks in advance

like image 985
Nick Avatar asked Aug 25 '14 04:08

Nick


People also ask

How do I customize my keyboard on my Iphone 8?

Go to Settings > General > Keyboard. Tap Keyboards, then do any of the following: Add a keyboard: Tap Add New Keyboard, then choose a keyboard from the list. Repeat to add more keyboards.

Does IOS custom keyboard?

Custom keyboards are enabled in the Settings app, under General > Keyboards. Once enabled, the keyboard is available during text entry within any app, except when editing secure text fields and phone number fields. People can enable multiple custom keyboards, and switch between them at any time.


1 Answers

Apparently, you are not the only person to try a keyboard like this. If you look at the animated GIF on the site, the keyboard uses copy/paste to add the image to the messages.

The UIKeyInput Protocol, which is inherited by UITextDocumentProxy, has the following function:

func insertText(_ text: String)     //Swift
- (void)insertText:(NSString *)text //ObjC

These only take a String or an NSString, as you already know. Because there are no other methods to insert content, it can be assumed that, currently, there is no other way.

Right now, I would suggest that you adopt a similar usage. When the user taps on the image, add it to the UIPasteboard. Maybe present a little banner on top of the keyboard saying, "You can now paste" or something, but that would be up to you to decide.

like image 143
erdekhayser Avatar answered Sep 22 '22 00:09

erdekhayser