Sending images with iOS 8 custom keyboard?

前端 未结 1 2013
深忆病人
深忆病人 2021-02-15 23:43

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 sim

相关标签:
1条回答
  • 2021-02-16 00:16

    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.

    0 讨论(0)
提交回复
热议问题