UIImageWriteToSavedPhotosAlbum只能保存10张图片。为什么? [英] UIImageWriteToSavedPhotosAlbum saves only 5 image out of 10. Why?
本文介绍了UIImageWriteToSavedPhotosAlbum只能保存10张图片。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有题目的问题。
是否有限制,例如每秒导出3张图像,或类似的东西?
for(int frameStepper = 0; frameStepper< [Something frameCount]; frameStepper ++)
{
//获取文件名。
imagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@frame_%i.jpg,frameStepper]];
//阅读图片。
UIImage * image = [[[UIImage alloc] initWithContentsOfFile:imagePath] autorelease];
//写图像。
UIImageWriteToSavedPhotos相册(image,nil,nil,nil);
}
此代码后,我有10个图像中导出了5个图像。看不出为什么请帮助,非常感谢。
解决方案
如果我记录完成的错误,它说:
错误域= ALAssetsLibraryErrorDomain代码= -3301写忙UserInfo = 0x69e8e20 {NSLocalizedFailureReason =由于写入资源繁忙,写入此资产时出现问题,NSLocalizedRecoverySuggestion =尝试再写一次,NSLocalizedDescription = Write busy}
这意味着我必须等待完成运行过程通过实现给定的回调:
- (void)image:(UIImage *)image
didFinishSavingWithError: (NSError *)错误
contextInfo:(void *)contextInfo
Hurray。 >
I have the problem as the title goes. Are there any restrictions, like "Export only 3 image per second", or something like?
for (int frameStepper = 0; frameStepper < [Something frameCount]; frameStepper++)
{
//Get the filename.
imagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"frame_%i.jpg", frameStepper]];
//Read image.
UIImage *image = [[[UIImage alloc] initWithContentsOfFile:imagePath] autorelease];
//Write image.
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}
I have 5 images exported out of 10 after this code. Cannot see why. Please help, many thanks.
解决方案
If I log the error of completion, it says:
Error Domain=ALAssetsLibraryErrorDomain Code=-3301 "Write busy" UserInfo=0x69e8e20 {NSLocalizedFailureReason=There was a problem writing this asset because the writing resources are busy., NSLocalizedRecoverySuggestion=Try to write again, NSLocalizedDescription=Write busy}
That means I have to wait for the completition of the running processes by implementing the given callback:
- (void) image: (UIImage *) image
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo
Hurray.
这篇关于UIImageWriteToSavedPhotosAlbum只能保存10张图片。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文