问题标签 [assetslibrary]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1681 浏览

iphone - ALAssetPropertyLocation not working on any iOS 4.0+ on 3gs iPhones but working perfectly on iPhone4

I've got an app with location services ENABLED (from settings etc), and I'm reading all the photos from my device using ALAssetsLibrary.

It works perfectly on iPhone4 iOS 4.2.1, but the same code and the same assets DONT WORK on any 3gs any iOS (from 4.0 to 4.2.1).

The problem is that it retrieves always an invalid CLLocation on the 3gs.

Even on the same picture (copied across both devices) on the iPhone4 returns a valid CLLocation, on the 3gs it returns invalid! The picture image itself it's valid on both devices, only the CLLocation is invalid. I dont have any crashes and the code doesnt step into any invalid blocks, it all works fine apart from the invalid CLLocation data.

Output of the same asset and same code and same iOS version (4.2.1):

iPhone4: <+51.23816667, -0.57700000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 19/02/2011 01:59:28 Greenwich Mean Time

3gs: < nan, nan > +/- 0.00m (speed -1.00 mps / course -1.00) @ 2011-02-19 01:20:35 +0000

(Note also the date on the invalid location is the current time)

Im getting the CLLocation like this:

The ALAssetsLibrary code called in my viewcontroller DidLoad looks like this (totally standard):

One last thing, on the native photo app the pictures are shown in the correct location on the 3gs, so they must have that data somewhere, it just doesnt read it somehow!

I'm not entirely sure it's a device (3gs) problem, normally it never is...

0 投票
1 回答
1599 浏览

objective-c - iOS 4 Assets Libraries 问题:NSMutableArray 包含 Block 中的数据,但 Block 调用后为空

我正在尝试将http://www.icodeblog.com/asset-libraries-and-blocks-in-ios-4/上的示例合并到我自己的应用程序中。这是我到目前为止所拥有的:

让我们(希望)同意每次调用 usingAssets 时,我都会将相册的最新内容添加到NSMutableArray* assets. 我将所有这些放在我的 ViewController 的 ViewDidLoad 中:

到目前为止,我相信我已经遵循了上面链接中显示的示例。问题是在 UserTabBarController 的范围内,assets.count保持为 0,而在 Block 的范围内,它显示计数在增加,并且在两个调用之间持续存在(正如我所预料的那样)。我还觉得奇怪的是,资产计数:0 行应该出现在日志中的更晚,或者查看资产的行(从块内调用)应该更早发生:

2011-02-21 14:22:59.140 iPCS[7219:207] 资产计数:0
2011-02-21 14:23:08.539 iPCS[7219:207] 资产计数:0

2011-02-21 14:14:03.363 iPCS[7139:207] 参见资产:ALAsset - 类型:照片,URL:{ "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext =JPG"; }
2011-02-21 14:14:03.363 iPCS[7139:207] 资产计数:1

2011-02-21 14:14:03.365 iPCS[7139:207] 参见资产:ALAsset - 类型:照片,URL:{“public.jpeg”=“assets-library://asset/asset.JPG?id=1000000002&ext =JPG"; }
2011-02-21 14:14:03.366 iPCS[7139:207] 资产数量:2

2011-02-21 14:14:03.367 iPCS[7139:207] AssetEnum:结果为零或列表结束
2011-02-21 14:14:03.367 iPCS[7139:207] GroupEnum 中的资产计数:2
2011-02- 21 14:14:03.368 iPCS[7139:207] GroupEnum:组 nil 或列表末尾
2011-02-21 14:14:03.368 iPCS[7139:207] GroupEnum 中的资产计数:2

2011-02-21 14:14:03.370 iPCS[7139:207] 参见资产:ALAsset - 类型:照片,URL:{“public.jpeg”=“assets-library://asset/asset.JPG?id=1000000001&ext =JPG"; 2011-02-21 14:14: 03.371
iPCS[7139:207] 资产数量:3

2011-02-21 14:14:03.373 iPCS[7139:207] 参见资产:ALAsset - 类型:照片,URL:{“public.jpeg”=“assets-library://asset/asset.JPG?id=1000000002&ext =JPG"; }
2011-02-21 14:14:03.374 iPCS[7139:207] 资产数量:4

2011-02-21 14:14:03.374 iPCS[7139:207] AssetEnum:结果为零或列表结束
2011-02-21 14:14:03.375 iPCS[7139:207] GroupEnum 中的资产计数:4
2011-02- 21 14:14:03.375 iPCS[7139:207] GroupEnum:组 nil 或列表末尾
2011-02-21 14:14:03.376 iPCS[7139:207] GroupEnum 中的资产计数:4

大家怎么说?

编辑:再进行一些测试,并usingAssets使用视图上的按钮调用,assets数组已正确填充!这意味着在加载时,在viewDidLoad块中看到的对象与在块的调用实例中看到的对象之间存在某种断开连接。任何人都对它为什么表现出这种行为有任何想法?

编辑 2:已经玩了一个多星期的代码,我仍然无法让资产 NSArray 准确显示内容。我已经确定它必须与块的执行顺序相关联。当我调用usingAssets时,方法本身完成,但块不会立即运行。所以,假设我将方法绑定到一个按钮,并立即打印它的内容assets,它是空的(我在库中有 2 张图像)。我再次单击按钮,现在内容显示 2 个项目。如果我第三次单击它,它会显示 4。几乎就像在将控制权返回给用户(返回应用程序循环)之后运行块一样,我正处于放弃的边缘,废弃了我的资产代码,只是根据它们存在的路径加载它们,但我宁愿使用资产,如果我能弄清楚为什么它没有按预期运行

0 投票
1 回答
803 浏览

ios - iOS AssetLibrary 存储指针

我有一个关于在 iOS 中使用 AssetLibrary 的问题。是否可以在您的应用程序中存储指向图像的指针而不是实际图像?假设我想创建一个播放列表,但我不想存储实际图像。

我问的原因是我发现当我使用图像选择器时,我可以将图像保存到设备文档目录中,但是一旦我达到 25 左右,它就会开始减慢设备(iPad 1)的速度。如果图像非常大,我会按比例缩小,我多次通过泄漏仪器运行,并且没有泄漏。我不知道下一步该去哪里,所以我想研究替代方案。因为我看不到可以释放内存的地方。

这就是我现在所处的位置,我很好奇 AssetLibrary 是否可能是一个选项,因为我不会存储物理图像。我知道它有一些缺点(需要用户位置,循环浏览图像时可能会有点慢)

对此的任何想法将不胜感激。

0 投票
3 回答
3169 浏览

iphone - 将元数据写入 ALAsset

我正在为 iPhone 开发视频应用程序。我正在录制视频并使用 AssetsLibrary 框架将其保存到 iPhone 相机胶卷。我使用的 API 是:

有没有办法使用 ALAsset 将视频的自定义元数据保存到相机胶卷。如果使用 AssetsLibrary 框架无法做到这一点,可以使用其他方法来完成。基本上,我有兴趣将有关我的应用程序的详细信息作为视频元数据的一部分编写。

0 投票
2 回答
2490 浏览

iphone - ALAssetsLibrary ALAssetsLibraryAccessUserDeniedError

当您第一次尝试访问用户的 ALAssetsLibrary 时,操作系统将向他们显示一个询问权限的对话框。如果他们不允许这样做,则将调用 failureBlock 并将在将来始终调用。有没有办法再次强制提示这个授权请求?

我注意到在地图应用程序中,他们通知用户转到设置应用程序以使用按钮打开位置服务。但是,我不知道以编程方式打开“设置”应用程序。我应该只显示有关如何打开位置服务的说明吗?

0 投票
1 回答
3591 浏览

ios - iOS ALAssetsLibrary 和 NSFileHandle 读取文件内容

我想在 iOS 中读取资产库文件的内容

NSFileHandle fileHandleForReadingFromUrl使用资产defaultRepresentationurl 似乎总是返回0x0......

在此期间,我会继续寻找解决方案。

编辑:

看起来 Anomie的答案可能是我想要的:

NSUInteger length = [representation getBytes:bytes fromOffset:0 length:[representation size] error:&error];

0 投票
1 回答
1005 浏览

cocoa-touch - AssetsLibrary:禁用位置服务提示

我使用 AssetsLibrary 来展示用户相机胶卷中的图片。但是我对这些图片的位置数据不感兴趣。有没有办法禁用此位置服务提示?

0 投票
2 回答
2619 浏览

iphone - 几次使用后 writeImageDataToSavedPhotosAlbum 显着变慢

我使用 api“writeImageDataToSavedPhotosAlbum”将图像保存到 iPhone 的相册中。但是,在多次使用(如 4 次)后,每次保存开始需要大约两倍的时间。

我创建了一个测试方法来重现它,它每次都保存完全相同的图像。方法如下:

在新重启的 iPhone 4 上,我得到以下保存时间。

怎么了?

0 投票
1 回答
365 浏览

ios - 将 Three20 ThumbViewer 与 AssetsLibrary 框架一起使用

我正在尝试TTThumbsViewController与框架结合使用AssetsLibrary来呈现一个类似于 iPhone 内置的照片库。

我正在尝试实现一个 Photo 类,该类实现NSObject<TTPhoto>和包装适当的属性,但被挂断了大小,这应该是一个CGSize.

简短的问题:

如何找到ALAsseta as a的尺寸CGSize

长问题:

我走在正确的道路上吗?有没有更简单的方法来做到这一点?

0 投票
1 回答
565 浏览

iphone - loadView 比通过 Assets 获取图像更快

所以,在初始化函数中,我通过 AssetsLibrary 获取图像

//initWithNibName:

//加载视图

从控制台登录:

2011-06-24 18:55:12.255 xxx[9450:207] 0 //

2011-06-24 18:55:12.306 xxx[9450:207] ALAsset - 类型:照片,网址:{ "public.jpeg" = "assets-library://asset/asset.JPG?id=1000000001&ext=JPG" ;

我很困惑。正如您在日志中看到的,loadView 执行代码的速度比 initWithNibName 快。这是因为通过 AssetLibrary 获取图像需要一些时间。但我认为所有这些代码都在一个线程中执行,所以 loadView 应该等待 initWithNibName。