Assets Library Framework not working correctly on 4.0 and 4.2

谁都会走 提交于 2019-12-22 01:08:08

问题


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/

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] 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"); 
}]; 

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


回答1:


Solved it, this was a real head breaker !

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

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 !!!




回答2:


You can output the error, then we will have more information about what's going on.

Replace this line:

NSLog(@"A problem occured");

with this one:

NSLog(@"A problem occured: %@", error);


来源:https://stackoverflow.com/questions/4200552/assets-library-framework-not-working-correctly-on-4-0-and-4-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!