【问题标题】:Ionic framework and angularjs imgcache not working on iOS device离子框架和 angularjs imgcache 在 iOS 设备上不起作用
【发布时间】:2015-08-11 07:08:33
【问题描述】:

我已经使用 ionic 框架构建了一个混合应用程序。 我使用了 angular imgcache (https://github.com/jBenes/angular-imgcache.js/tree/master) 来允许缓存从外部站点获取的图像。

我正在使用如下代码:

<img img-cache ic-src="{{src}}"/>

它在浏览器中(在使用 'ionic serve' 之后)在命令行中工作。 我已经在 ionic view iOS 应用程序中对其进行了测试。 我现在已经获取了它创建的 xcodeproj 并将其分发以进行测试,但图像没有加载。

我什至添加了科尔多瓦白名单插件并设置元数据以允许 CORS 请求。

有没有人有任何其他想法可能是什么问题?

【问题讨论】:

  • 这里有同样的问题。在浏览器中工作但不在设备上工作(但是我目前正在使用 ionicView 这可能是原因)。我遵循文档并确保在平台准备好时 $init() 缓存

标签: angularjs ionic-framework caching hybrid-mobile-app


【解决方案1】:

首先,确保在 app.config 函数中将 img 缓存设置为手动初始化 ImgCacheProvider.manualInit = true;。

第二步 - 在 deviceready 事件之后的任何时间调用ImgCache.$init()(在您的情况下,在$ionicPlatform.ready 函数中的某处)。

【讨论】:

    【解决方案2】:

    如果您没有访问 HTTPS 端点,您可能会受益于检查 .plist 文件(位于platforms/ios/{app_name}/{app_name}-Info.plist 中)中的应用传输安全设置

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
    <plist version="1.0">
      <dict>
        ...
        <key>NSAppTransportSecurity</key>
        <dict>
          <key>NSAllowsArbitraryLoads</key>
          <true/>
        </dict>
      </dict>
    </plist>
    

    来自此资源:Publishing an Ionic Angular App for iOS - The Hidden Steps & Pitfalls 。

    【讨论】:

      猜你喜欢
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      • 2018-09-20
      • 1970-01-01
      相关资源
      最近更新 更多