save image:-
UIImageView *
UIImage *contactImage = contactImageView.image;
NSData *imageData = UIImageJPEGRepresentation(contactImage, 100);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:imageData forKey:@"image"];
[[NSUserDefaults standardUserDefaults] setObject:UIImagePNGRepresentation(
forKey:@"imageKey"];
//choose image from Library
- (IBAction)chooseImage:(id)sender {
UIImagePickerController *picker = [[[UIImagePickerController alloc] init] autorelease];
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
#pragma mark - Image Picker Delegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
contactImageView.image = image;
[picker dismissModalViewControllerAnimated:YES];
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
[picker dismissModalViewControllerAnimated:YES];
}
code for get image:
-(IBAction)getImage:(id)sender
{
UIImageView *contactImageView1=[[UIImageView alloc]initWithFrame:CGRectMake(x,y,w,h)];
[self.view addSubview:contactImageView1];
NSData* imageData = [[NSUserDefaults standardUserDefaults] objectForKey:@"image"];
UIImage* image = [UIImage imageWithData:imageData];
contactImageView1.image=image;