CGAffineTransformInvert: singular matrix in UIImagePickerController with showsCameraControls = NO

删除回忆录丶 提交于 2019-11-30 05:59:41

问题


I tried this twice with two different apps and I get the same thing. I have a set up a UIImagePIckerController instance as follows:

- (IBAction)addImage:(UIBarButtonItem *)sender {


    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
        if ([mediaTypes containsObject:(NSString *)kUTTypeImage]) {
            UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypeCamera;
            picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage];
            picker.allowsEditing = NO;
            picker.showsCameraControls = NO;

            [self presentViewController: picker animated:YES completion:NULL];

        }           
 [..]   

}

This was the second. In the first I set up a custom overlay to run the shutter and other functions. Everything runs fine but I keep getting an error on the console:

 <Error>: CGAffineTransformInvert: singular matrix.

When I run the app, every time I rotate (or move about which signals a rotate) the device while the camera is up {something happens here}. I tried it on both my iPhone 4 and iPad Mini with the same results. After a lot of digging I found this only happen in the case where

picker.showsCameraControls = NO;

If I put

picker.showsCameraControls = YES;

Then I get no message (though my custom overlay is hidden too). Making sure it wasn't the custom overlay itself I tried leaving that out, and it still gives the error message.

Anybody got any ideas of what I should do about this?


回答1:


I believe it to be largely benign as Apple's own PhotoPicker sample code generates this warning. Rotation has to do with matrices and while I'm not sure which matrix in particular is getting rotated, it is considered a mathematical violation to perform operations on matrices with a determinant of zero (similar to dividing by zero). Such a matrix is not invertible or 'singular':

http://en.wikipedia.org/wiki/Rotation_matrix

http://en.wikipedia.org/wiki/Determinant

http://en.wikipedia.org/wiki/Singular_matrix#singular



来源:https://stackoverflow.com/questions/13708496/cgaffinetransforminvert-singular-matrix-in-uiimagepickercontroller-with-showsca

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!