I'm using the Custom Picker by ray, when I press a button a picker is pop-ups then when image is chosen it will dismiss the picker and displayed the image in UIImageView. I put in the viewWillAppear
but when I go to another ViewController
the image chosen disappears. How to maintain the chosen in UIImageView to be displayed even after going to different View Controllers, only will it change if another image is chosen again.
- (void)viewWillAppear:(BOOL)animated {
secondView.image = _imagePicker.selectedImage;
}
- (IBAction)chooseCustomImageTapped:(id)sender {
_imagePicker = [[CustomImagePicker alloc] init];
_imagePicker.title = @"Choose Custom Image";
for(int i = 0; i <= 10; i++)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Images%d.png", i]];
if([[NSFileManager defaultManager] fileExistsAtPath:savedImagePath]){
[_imagePicker addImage:[UIImage imageWithContentsOfFile:savedImagePath]];
}
}
[self presentModalViewController:_imagePicker animated:NO];
}