【问题标题】:On demand resources in iOS 9 - how to find out exact location of downloaded resources?iOS 9 中的按需资源 - 如何找出下载资源的确切位置?
【发布时间】:2015-11-20 10:38:08
【问题描述】:

我正在尝试在不使用 xcasset 的游戏中使用 ODR。

所以,我有一个带有标签的纹理(例如“教程”),在项目设置中将其设为 ODR,并使用下面的代码下载它:

NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
    if (resourcesAvailable) {
        // Upload the texture
    }
    else
    {
        [resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
            if (error) {
                NSLog(@"Failed to load assets pack");
            }
            else
            {
                // Upload the texture
            }
        }];

    }
}];

主包不包含有问题的纹理(我在模拟器文件夹中查看了包)。调用XCode上面的代码后,logs报告下载成功,可以使用了。

// Upload the texture 的注释在哪里,我需要调用我的代码来将纹理上传到视频内存中,但问题是 - 我无法获取下载文件的确切位置。

有没有办法知道下载资源的位置?

【问题讨论】:

  • [[NSBundle mainBundle] pathForResource:ofType] 有点作用
  • Charles 或 Wireshark 网络嗅探器可能会有所帮助,但可能不会,这只是一个想法

标签: ios ios9 app-thinning on-demand-resources


【解决方案1】:

今天发生在我身上,这是链接下的资产图片 TARGET -> Resource Tags 检查是否在此处添加了资产中的任何图像。如果它在那里而不是删除并重建。

【讨论】:

    【解决方案2】:

    在 NSBundleResourceRequest 中提供了一个包,您可以使用它来获取资源。见Apple's Docs on NSBundleResourceRequest

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多