【发布时间】:2017-08-17 11:17:43
【问题描述】:
我希望在我的应用程序中访问 iOS 字典。 iOS 的构建库中是否有任何提供特定单词的定义。
我发现许多第三方 API 可以完成这项工作,但它们是有偿的。
寻找最佳解决方案...
【问题讨论】:
标签: ios
我希望在我的应用程序中访问 iOS 字典。 iOS 的构建库中是否有任何提供特定单词的定义。
我发现许多第三方 API 可以完成这项工作,但它们是有偿的。
寻找最佳解决方案...
【问题讨论】:
标签: ios
斯威夫特 3
if UIReferenceLibraryViewController.dictionaryHasDefinition(forTerm: "word") {
let libraryVC = UIReferenceLibraryViewController(term: "word")
self.present(libraryVC, animated: true, completion: nil)
}
代码本身很清楚,不需要解释
【讨论】:
是的,可以试试UIReferenceLibraryViewController:
除了定义之外,它还包括检查给定单词是否已定义。您可以按如下方式使用它:
目标-C:
if ([UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:@"definition"]) {
UIReferenceLibraryViewController* ref =
[[UIReferenceLibraryViewController alloc] initWithTerm:@"definition"];
[currentViewController presentViewController:ref animated:YES completion:nil];
}
斯威夫特:
if UIReferenceLibraryViewController.dictionaryHasDefinition(forTerm: "definition") {
let libraryVC = UIReferenceLibraryViewController(term: "definition")
self.present(libraryVC, animated: true, completion: nil)
}
【讨论】: