How do you save a picture with NSUserDefaults?

你离开我真会死。 提交于 2019-12-24 19:36:11

问题


I have a iPad app that can take a picture and then put it within a image view. How do I go about saving the pic that I have stored in the image view? Here is what I have tried so far: [imageView setImage:[[NSUserDefaults standardUserDefaults] objectForKey:@"storedImageValue6"]];


回答1:


Pretty much you have to convert it to NSData and vice versa. Take a look at this link: Save images in NSUserDefaults?




回答2:


Here imageSet is UIImage

 NSData *imagedata=UIImagePNGRepresentation(imageSet);
[[NSUserDefaults standardUserDefaults] setObject:imagedata forKey:@"Theme Selecting"];    
[[NSUserDefaults standardUserDefaults] synchronize];

You can use this code for saving image



来源:https://stackoverflow.com/questions/9058825/how-do-you-save-a-picture-with-nsuserdefaults

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!