Reputation: 29767
I am trying to set a UIButton
image with the image chosen from an image picker. My code looks like this:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[picker dismissViewControllerAnimated:YES completion:nil];
UIImage *editedImage = [info objectForKey:UIImagePickerControllerEditedImage];
// Resize image
UIGraphicsBeginImageContext(CGSizeMake(478, 640));
[editedImage drawInRect: CGRectMake(0, 0, 478, 640)];
UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[self.cameraButton setImage:smallImage forState:UIControlStateNormal];
}
When this code executes it removes the original image I had set and shows nothing. If I click the space where the image button was, it still kicks off the IBAction
, but no image.
I have connected the IBOoutlet
so it is not that.
What am I doing wrong?
Upvotes: 0
Views: 197
Reputation: 29767
whoops, UIImagePickerControllerEditedImage
should be UIImagePickerControllerOriginalImage
Upvotes: 1