IOS 8:自定义键盘,带撤消和重做按钮

我开发了一个
IOS 8自定义键盘.我想给它“撤消”和“重做”功能,就像默认的系统键盘一样.我以不同的方式尝试过,但无法找到一个好的解决方案.

我们可以使用方法与文本输入对象textDocumentProxy进行交互

insertText
deleteBackward
documentContextAfterInput
ocumentContextBeforeInput

但我无法找到任何实现“撤消”和“重做”功能的方法.

最佳答案 我想我们不能实现这些功能(撤消,重做)

根据https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html

Because a custom keyboard can draw only within the primary view of its
UIInputViewController object, it cannot select text. Text selection is
under the control of the app that is using the keyboard. If that app
provides an editing menu interface (such as for Cut, Copy, and Paste),
the keyboard has no access to it
. A custom keyboard cannot offer
inline autocorrection controls near the insertion point.

我认为很多情况下文本字段的内容发生了变化,你无法知道它何时发生变化,变化如何.如果我们无法知道,我们也无法知道撤消到哪里.我认同.

我正在开发像你这样的自定义键盘扩展,我有很多问题. (例如:我们如何知道当前光标以获取当前文本…)

我的问题:Current text selection in CustomKeyBoardExtension(希望有人知道)

点赞