I have used an ImagePickerController as a View as:
camViewController* camera = [[camViewController alloc] init];
[camera setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:camera animated:YES completion:nil];
camera.showsCameraControls = NO;
So the view shows the user data from camera. And there is an opportunity to cover this view with an image, which may be taken from Photo Library or from Camera.
In this View I've created another ImagePickerController SourceTypeCamera, but when the image is taken and the camera dismisses, camViewController (the first one) shows just a black screen.
UPD: When the image is taken from Photo Library - everything is ok - the image becomes an overlay over the camViewController and the user can see both: the image (alpha 0.5) and the footage from camera.
This is the code:
- (IBAction)chooseImageAction:(id)sender {
choosePhoto = [[UIImagePickerController alloc] init];
[choosePhoto setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
choosePhoto.delegate = self;
[self presentViewController:choosePhoto animated:YES completion:nil];
}
- (IBAction)getImageAction:(id)sender {
getPhoto = [[UIImagePickerController alloc] init];
[getPhoto setSourceType:UIImagePickerControllerSourceTypeCamera];
getPhoto.delegate = self;
[self presentViewController:getPhoto animated:NO completion:nil];
}
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)choosePhoto {
[self dismissViewControllerAnimated:NO completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)choosePhoto didFinishPickingMediaWithInfo:(NSDictionary *)info {
self.shownImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (getPhoto) {
UIImageWriteToSavedPhotosAlbum(shownImage.image, self, nil, nil);
}
[self dismissViewControllerAnimated:NO completion:nil];
}
How to avoid getting the black screen when I take image with the camera?