I am trying to get a image that is take from a camera and place than taken image into a UIImageView (without using the camera roll - just directly from the camera to the UIImageView). I have tried my best for weeks to try to work around this with no success. Does anyone have an idea why this does not work?
FYI, What have I been doing?
- Using this code below
- Press button to open camera UI
- Press capture button to take image
- Press the "use photo" button to select photo
- Expecting the photo to be placed in the UIImageView on the screen (But it doesn't...)
- Feelings of frustration
I'd be grateful if a wise coder can help me figure this one out. I feel like I'm doing everything that I'm reading others are telling me to do. Any code typed corrections would be extremely helpful. Thank you!
- (IBAction)cameraButtonPushed:(id)sender {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) {
//todo if device has no camera
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unable To Locate Camera" message:@"No Camera found." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
else {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.delegate = delegate;
cameraUI.allowsEditing = YES;
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeCamera];
[self presentViewController:cameraUI animated:YES completion:^{
}];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:^{
UIImage *takenImage = [info valueForKey:UIImagePickerControllerEditedImage];
[self.navigationController pushViewController:self animated:YES];
image = [[UIImageView alloc] initWithImage:takenImage];
}];
}