I am playing around with Xcode 5 and storyboarding. I'm at the point where I have captured a UIImage
using the camera, but I can't figure out how to display the image on the phone after I've captured it. I have specified an IBOutlet UIImageView
and set it's value to the image that I captured from the camera, but that doesn't seem to do anything at all.
This is my interface:
@interface HCViewController ()
@property (nonatomic, retain) IBOutlet UIImageView *image;
@end
And this is my didFinishPickingWithMediaInfo
method:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the picture from the camera
UIImage *imageFromCamera = [info objectForKey:UIImagePickerControllerEditedImage];
// Set the IBOutlet UIImageView to the picture from the camera
// This does nothing as far as I can tell
self.image = [[UIImageView alloc] initWithImage:imageFromCamera];
// Let's take a closer look at this
NSLog(@"%@", self.image);
// Close the camera view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
This is what I see in the logger for self.image
:
2013-09-10 17:17:45.169 YourMom[6136:60b] <UIImageView: 0x1556fdc0; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x155d5b10>>
My storyboard has a View Controller with two different scenes that can be swiped back and forth. Both of the scenes have a "View" with an "Image View" as a sub-item. The Image Views each have "Referencing Outlets" that seem to be connected to the image
variable that I defined in my interface. However, simply setting the value of image
doesn't change the phone display.
After reading this SO question: How can I change the image displayed in an UIImageView programmatically? I tried [self.image setImage:image]
, but that didn't appear to do anything either. How do I tell Xcode that I want image
to show up in the view?