【问题标题】:react-native-text-detector worked fine in android but why it always returned false in iOS?react-native-text-detector 在 android 中运行良好,但为什么它在 iOS 中总是返回 false?
【发布时间】:2020-01-14 02:29:55
【问题描述】:

首先,我使用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 从该图像中获取文本

它在android中运行良好,但在iOS中总是返回false,我在控制台日志中发现了以下错误

NSURLConnection 完成错误 - 代码 -1002

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

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

该 URI 或应用程序权限是否有问题?

【问题讨论】:

    标签: ios react-native ocr


    【解决方案1】:

    由于 Apple https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html 的沙盒策略,您的应用无法直接读取图库中的照片,它会遇到错误:NSURLConnection finished with error - code -1002。

    这是我的方法:

    • 使用 RNFS.copyAssetsFileIOS 将照片复制到应用文档中的临时文件
    • 使用 react-native-text-detector 分析该临时文件

    完整示例推送到https://github.com/haison8x/react-native-test-ocr

    【讨论】:

      猜你喜欢
      • 2020-07-15
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 1970-01-01
      • 2020-06-04
      相关资源
      最近更新 更多