【问题标题】:IOS Dictonary to get the Defination of particular Word [duplicate]IOS字典获取特定单词的定义[重复]
【发布时间】:2017-08-17 11:17:43
【问题描述】:

我希望在我的应用程序中访问 iOS 字典。 iOS 的构建库中是否有任何提供特定单词的定义。

我发现许多第三方 API 可以完成这项工作,但它们是有偿的。

寻找最佳解决方案...

【问题讨论】:

    标签: ios


    【解决方案1】:

    斯威夫特 3

      if UIReferenceLibraryViewController.dictionaryHasDefinition(forTerm: "word") {
                let libraryVC = UIReferenceLibraryViewController(term: "word")
                self.present(libraryVC, animated: true, completion: nil)
            }
    

    代码本身很清楚,不需要解释

    【讨论】:

      【解决方案2】:

      是的,可以试试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)
      }
      

      【讨论】:

        猜你喜欢
        • 2020-04-18
        • 2018-08-14
        • 1970-01-01
        • 2019-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-10-16
        相关资源
        最近更新 更多