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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -