Assets Library Framework not working correctly on 4.0 and 4.2
I have tried to implement the Asset Library and create a Custom Image Picker. Specifically, I a开发者_如何学JAVAm 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.
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 !!!
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);
精彩评论