我正在努力使用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];
}
答案 0 :(得分:0)
我的相机遇到了同样的问题。我修改或编辑相机图像的屏幕显示为黑色。日志显示我同样的错误(CGAffineTransformInvert xx)。我做了很多检查以确定或知道错误在哪里。
在我的应用程序中,我使用组件SVProgessHUD来显示警报和消息。使用此用法注释行可以解决问题。我已更新到组件的最后一个版本(1.0),错误CGAffineTransformInvert消失。