我使用了ImagePickerController作为View:
camViewController* camera = [[camViewController alloc] init];
[camera setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:camera animated:YES completion:nil];
camera.showsCameraControls = NO;
因此视图显示来自摄像头的用户数据。并且有机会用图像覆盖此视图,该图像可以从照片库或相机中拍摄。
在这个视图中我创建了另一个ImagePickerController SourceTypeCamera,但是当拍摄图像并且相机解散时,camViewController(第一个)只显示黑屏。
UPD:当从照片库中拍摄图像时 - 一切正常 - 图像成为camViewController上的叠加图,用户可以看到图像(alpha 0.5)和来自摄像头的镜头。
这是代码:
- (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];
}
使用相机拍摄图像时如何避免黑屏?