I want to store and retrieve an image that was taken from my avcapturesession. I was able to do this with a button press but I want to have the image appear automatically after it is taken. It works fine with an IBAction press. Here's what I have done. I stored the image to user defaults with this code
UIImage *Capture = [UIImage imageWithData:self.jpegPhotoData];
capturetest = Capture;
NSData *imageData;
imageData = [NSKeyedArchiver archivedDataWithRootObject:Capture];
[[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"image"];
Then I called the NSUserDefaults with a button press using this code.
-(IBAction)test:(id)sender
{
NSLog(@"WAS IT PRESSED");
NSData *imageData1;
imageData1 = [[NSUserDefaults standardUserDefaults] objectForKey:@"image"];
capturetest = [NSKeyedUnarchiver unarchiveObjectWithData: imageData1];
self.imgView.image = capture test;
}
This worked perfect. When I pressed the button it showed the image I just took but how do I just get the image to appear automatically? I've tried putting the button code inside a void statement like -(void)test
then after the photo was taken I called [self test]
. That didn't work. I even tried to call the button press automatically like this but no luck.
[self performSelector: @selector(test:) withObject:self afterDelay: 0.0];