如何在我自己的 iOS8 自定义键盘扩展中实现 Apple 的预测输入面板?
Apple 的自定义键盘 API 文档自定义键盘 状态:
RequestsOpenAccess在 info.plist 中设置yes 可以通过 UILexicon 类BOOL访问基本词典。autocorrection使用这个类,连同你自己设计的词典,在用户输入文本时suggestions提供autocorrections。
但我找不到如何UILexicon在我的自定义键盘中使用。我将RequestsOpenAccess设置设置为YES:

但是仍然无法访问自定义词典以获取单词建议,例如 Apple 的 iOS8 默认键盘:

我的自定义键盘看起来像:

编辑:
我发现requestSupplementaryLexiconWithCompletion用于UILexicon class这样的我尝试使用以下代码来实现它:
- (void)viewDidLoad {
[super viewDidLoad];
[self requestSupplementaryLexiconWithCompletion:^(UILexicon *appleLex) {
appleLexicon = appleLex;
NSUInteger lexEntryCount = appleLexicon.entries.count;
for(UILexiconEntry *entry in appleLexicon.entries) {
NSString *userInput = [entry userInput];
NSString *documentText = [entry documentText];
lable.text=userInput;
[lable setNeedsDisplay];
}
}];
}
