资产库框架在4.0和4.2上无法正常工作 [英] Assets Library Framework not working correctly on 4.0 and 4.2

查看:127
本文介绍了资产库框架在4.0和4.2上无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试实现资源库并创建自定义图像选择器。具体来说,我正在尝试运行此处给出的代码: http://icodeblog.com/2010/10/07/cloning-uiimagepickercontroller-using-the-assets-library-framework/

I have tried to implement the Asset Library and create a Custom Image Picker. Specifically, I am trying to run the code given here: http://icodeblog.com/2010/10/07/cloning-uiimagepickercontroller-using-the-assets-library-framework/

代码在Simulator 4.1中运行得非常好但是当我尝试使用4.0或4.2时,它会卡在加载屏幕上,它会在GDB上给出以下评论:

The code runs perfectly well in Simulator 4.1 but when I try 4.0 or 4.2 it gets stuck on the Loading screen and it gives me the following comment on the GDB:


2010-11-16 16:37:27.514 ELCImagePickerDemo [49819:6b03]问题
发生

2010-11-16 16:37:27.514 ELCImagePickerDemo[49819:6b03] A problem occured

它来自代码中的这一行:

It's from this line in the code:

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:assetGroupEnumerator failureBlock:^(NSError *error) 
{ 
    NSLog(@"A problem occured"); 
}]; 

不知怎的,我无法弄清问题是什么。我已经添加了Asset Lib框架和所有内容。

Somehow I am not able to figure out what is the problem. I have added the Asset Lib framework and everything.

推荐答案

解决了这个问题,这是一个真正的破坏者!

Solved it, this was a real head breaker !

好的,所以我检查了苹果论坛,这个家伙发帖真的很有帮助:
https://devforums.apple.com/message/323036#323036

Ok so I checked the apple forum and this guys post really helped : https://devforums.apple.com/message/323036#323036

所以基本上assetGroupEnumerator在自己的线程上运行所以我只是将整个函数包含在dispatch_async(dispatch_get_main_queue()中,它现在可以工作!!!

so basically assetGroupEnumerator runs on its own thread so I just enclosed the whole function in dispatch_async(dispatch_get_main_queue() and it works now !!!

这篇关于资产库框架在4.0和4.2上无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆