代码之家  ›  专栏  ›  技术社区  ›  Jacob Phan

react原生文本检测器在android中运行良好,但为什么在iOS中总是返回false?

  •  0
  • Jacob Phan  · 技术社区  · 5 年前

    https://github.com/jeanpan/react-native-camera-roll-picker#readme 为了从照片库获取图像,它返回了一个uri:ph://11A68DD6-A651-462D-BDAB-68FB853ED141/L0/001

    然后,我用 https://github.com/zsajjad/react-native-text-detector 从图像中获取文本

    NSURLConnection已完成,错误代码为-1002

    有关详细信息,图像控件可以正确显示该图像

    这是我的源代码: https://github.com/haison8x/react-native-test-ocr

    那个URI或应用程序权限有问题吗?

    0 回复  |  直到 5 年前
        1
  •  0
  •   Jacob Phan    5 年前

    因为苹果的沙箱政策 https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html ,您的应用程序无法直接读取库中的照片,它将遇到错误:NSURLConnection finished,错误代码为-1002。

    我的方法是:

    • 使用react本机文本检测器分析临时文件

    完整的例子被推到 https://github.com/haison8x/react-native-test-ocr