0

我在 UIImagePickerController 上苦苦挣扎,因为当我打开相机并拍摄图像时,它在 IOS 7 中显示黑屏,因为这在 ios 6 中运行良好,我尝试了一些其他链接,但它不起作用,请帮我解决这个问题...

我也收到了这个错误

<Error>: CGAffineTransformInvert: singular matrix.

现在我得到了一些东西..

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

当我点击拍照按钮时

拍摄后的图像

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (buttonIndex == 0) {

                if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {

                    NSString *mediaType = AVMediaTypeVideo; // Or AVMediaTypeAudio



                AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];

                // This status is normally not visible—the AVCaptureDevice class methods for discovering devices do not return devices the user is restricted from accessing.
                if(authStatus == AVAuthorizationStatusRestricted){
                    NSLog(@"Restricted");
                }

                // The user has explicitly denied permission for media capture.
                else if(authStatus == AVAuthorizationStatusDenied){
                    NSLog(@"Denied");
                }

                // The user has explicitly granted permission for media capture, or explicit user permission is not necessary for the media type in question.
                else if(authStatus == AVAuthorizationStatusAuthorized){
                    NSLog(@"Authorized");

                    if  ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
                        UIImagePickerController *imagePickerCamera =[[UIImagePickerController alloc] init];
                        imagePickerCamera.delegate = self;
                        imagePickerCamera.allowsEditing = YES;
                        imagePickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
                        dispatch_async(dispatch_get_main_queue(), ^{
                            [self presentViewController:imagePickerCamera  animated:YES completion:^{}];
                        });

                    } else {

                        NSString *errorString = [NSString stringWithFormat:@"This device does not support this feature."];
                        UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                        [errorAlert show];
                    }
                }

                // Explicit user permission is required for media capture, but the user has not yet granted or denied such permission.
                else if(authStatus == AVAuthorizationStatusNotDetermined){

                    [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
                        if(granted){
                            NSLog(@"Granted access to %@", mediaType);
                        }
                        else {
                            NSLog(@"Not granted access to %@", mediaType);
                        }
                    }];

                }

                else {
                    NSLog(@"Unknown authorization status");
                }
            }

            else {
                if  ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
                    dispatch_async(dispatch_get_main_queue(), ^{
                        UIImagePickerController *imagePickerCamera =[[UIImagePickerController alloc] init];
                    imagePickerCamera.delegate = self;
                    imagePickerCamera.mediaTypes = @[(NSString *) kUTTypeImage];
                    imagePickerCamera.allowsEditing = YES;
                    imagePickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
                        [self presentViewController:imagePickerCamera  animated:YES completion:nil];
                    });
                } else {

                    NSString *errorString = [NSString stringWithFormat:@"This device does not support this feature."];
                    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [errorAlert show];
                }
            }


        } else if (buttonIndex == 1) {


            if  ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
                UIImagePickerController *imagePickerAlbum =[[UIImagePickerController alloc] init];
                imagePickerAlbum.delegate = self;
                imagePickerAlbum.mediaTypes = @[(NSString *) kUTTypeImage];
                imagePickerAlbum.allowsEditing = YES;
                imagePickerAlbum.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

                [self presentViewController:imagePickerAlbum animated:YES completion:nil];
            } else {

                NSString *errorString = [NSString stringWithFormat:@"This device does not support this feature."];
                UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [errorAlert show];
            }
        }
    });
}


    - (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {

[picker dismissModalViewControllerAnimated:YES];
_upLoadimage = info[UIImagePickerControllerEditedImage];

}

4

1 回答 1

0

我的相机也有同样的问题。我修改或编辑相机图像的屏幕显示为黑色。日志显示了同样的错误(CGAffineTransformInvert xx)。我做了很多检查以确定或知道错误在哪里。

在我的应用程序中,我使用组件 SVProgessHUD 来显示警报和消息。用这种用法注释行可以纠正问题。我已经更新到组件的最新版本(1.0)并且错误 CGAffineTransformInvert 消失了。

于 2014-01-16T12:55:07.073 回答