
Question:
A user can select a photo from their library using the image picker - I want to remember this selection and display this picture in future without the user having to pick it. How can I reference the specific photo or is there a way I can copy the photo to my application's storage?
Solution:1
you can save the selected image by converting it into NSData object and then writing it on the iphone file system under your app's document directory like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { NSData *imageData = UIImagePNGRepresentation(image); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"SavedImage"]; [imageData writeToFile:filename atomically:NO]; }
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon