ios - UIImageWriteToSavedPhotosAlbum freezes the app -


so have interesting problem.

when call uiimagewritetosavedphotosalbum freezes app , don't know why.

so code have

uiimagewritetosavedphotosalbum(leftimage, self,  @selector(image:didfinishsavingwitherror:contextinfo:), nil);  uiimagewritetosavedphotosalbum(rightimage, self,  @selector(image:didfinishsavingwitherror:contextinfo:), nil);  - (void)image:(uiimage *)image didfinishsavingwitherror:(nserror  *)error contextinfo: (void *)contextinfo {   if (error != nil)   {     nslog(@"image can not saved");   }   else   {     nslog(@"successfully saved image");   } } 

so works , doesn't. when remove 2 lines, never freezes. can go wrong. assuming can't see didfinishsavingwitherror because app freezes.

here stack enter image description here

the problem calling method twice in succession:

uiimagewritetosavedphotosalbum(leftimage, self,  @selector(image:didfinishsavingwitherror:contextinfo:), nil); uiimagewritetosavedphotosalbum(rightimage, self,  @selector(image:didfinishsavingwitherror:contextinfo:), nil); 

but method takes time complete. can't call second time until has completed. that's didfinishsavingwitherror — it's know when has completed, , safe call again.

thus, solution is, don't call uiimagewritetosavedphotosalbum second time until didfinishsavingwitherror has been called first time.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -