UIImageWriteToSavedPhotosAlbum saves only 5 image out of 10. Why?

后端 未结 2 443
温柔的废话
温柔的废话 2021-01-03 14:46

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 =         


        
相关标签:
2条回答
  • 2021-01-03 15:21

    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.

    0 讨论(0)
  • 2021-01-03 15:37

    A variation of this helped me: http://iphoneincubator.com/blog/tag/uiimagewritetosavedphotosalbum

    {
        UIImageWriteToSavedPhotosAlbum(image, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);
    
    }
    
    
    - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
        if (error) {
            [self tryWriteAgain:image];
        }
    }
    
    -(void)tryWriteAgain:(UIImage *)image
    {
        UIImageWriteToSavedPhotosAlbum(image, self, @selector(imageSavedToPhotosAlbum: didFinishSavingWithError: contextInfo:), nil);
    }
    
    0 讨论(0)
提交回复
热议问题