Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 views
in Technique[技术] by (71.8m points)

iphone - CGAffineTransformInvert: singular matrix in UIImagePickerController with showsCameraControls = NO

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...