I have an app that takes a photo and puts it in an image view. Simple. Code looks like this:
- (void)takePhoto:(id)sender
{
// Lazily allocate image picker controller
if (!imagePickerController) {
imagePickerController = [[UIImagePickerController alloc] init];
// If our device has a camera, we want to take a picture, otherwise, we just pick from
// photo library
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
}else
{
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
// image picker needs a delegate so we can respond to its messages
[imagePickerController setDelegate:self];
}
// Place image picker on the screen
[self presentModalViewController:imagePickerController animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
image = [ImageHelpers imageWithImage:image scaledToSize:CGSizeMake(480, 640)];
[imageView setImage:image];
[self dismissModalViewControllerAnimated:YES];
}
When I use the Camera Roll everything works great, but if I use the actual Camera the image view is just black. Why is that?
Do I need to save it to the camera roll before I use it in the image view?
Select the photo that you want to change. Tap Edit. Tap Portrait at the top of your screen. Tap Done.
Apple offers some of the best cameras to be found on smartphones, especially if you have the latest iPhone Pro or Pro Max. Even professional photographers are using iPhones for some photography work and there's no denying that it's possible to get incredible shots.
The Live Photos icon (three circles) is at the top right of the screen. If it doesn't have a line through it, Live Photos is switched on. If the icon has a line through it, tap it to turn on Live Photos. A Live Photo captures 3 seconds of movement and sound.
As a general rule, mobile phones are not able to capture higher-quality images than a DSLR. But many photographers believe their images taken on a mobile phone look better because the phone automatically adds contrast, saturation, skin softening, and background blur.
Ok. Found the solution myself.
I had to dismiss the modal view first...
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissModalViewControllerAnimated:YES]; //Do this first!!
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
image = [ImageHelpers imageWithImage:image scaledToSize:CGSizeMake(480, 640)];
[imageView setImage:image];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With