If the showsCameraControls is set to NO and change the orientation of the device, in the XCode console there will be a error message, even if the app do not support to change orientation.
<Error>: CGAffineTransformInvert: singular matrix
I track the code and find the it trigger this erro in CGAffineTransformInvert function, but have no souce code of this function. Firstly I try to remove any orientation changed notification of the UIImagePicker, but find it have not observer. Then I try to find out the view layout of the pick, list bellow:
UILayoutContainerView {{0, 0}, {320, 480}} { UINavigationTransitionView {{0, 0}, {320, 480}} { UIViewControllerWrapperView {{0, 0}, {320, 480}} { PLCameraView {{0, 0}, {320, 480}} { UIView {{0, 0}, {320, 480}} { PLCameraPreviewView {{0, 1}, {320, 426}} { UIView {{0, 0}, {320, 426}} { UIView {{0, 0}, {320, 426}} { UIView {{0, 0}, {320, 426}} } UIView {{0, 0}, {320, 426}} } } } PLPreviewOverlayView {{0, 0}, {320, 427}} { PLCameraFlashButton {{10, 10}, {81, 35}} { UIImageView {{0, 0}, {81, 35}} UIImageView {{10, 7.5}, {15, 20}} PLCameraOverlayButtonLabel {{30, 8}, {35, 19}} PLCameraOverlayButtonLabel {{65, 8}, {0.0022, 19}} PLCameraOverlayButtonLabel {{66.0022, 8}, {0.0023, 19}} PLCameraFlashButtonSpacerView {{65, 1}, {0, 33}} PLCameraFlashButtonSpacerView {{65.0022, 1}, {1, 33}} } PLCameraToggleButton {{240, 10}, {70, 35}} { UIImageView {{0, 0}, {70, 35}} UIImageView {{10, 5}, {50, 25}} } UIView {{160, 417}, {0, 0}} } UIImageView {{0, 0}, {320, 480}} UIImageView {{0, 422}, {320, 5}} PLCropOverlay {{0, 0}, {320, 480}} { PLCameraIrisAnimationView {{0, 0}, {320, 480}} PLCropOverlayBottomBar {{0, 427}, {320, 53}} { UIImageView {{320, 0}, {320, 53}} { PLCropOverlayBottomBarButton {{0, 0}, {71, 41}} { UIImageView {{0, 0}, {71, 41}} UIButtonLabel {{15, 10.5}, {41, 15}} } PLCropOverlayBottomBarButton {{0, 0}, {56, 41}} { UIImageView {{0, 0}, {56, 41}} UIButtonLabel {{0, 17.5}, {0, 0}} } } UIImageView {{0, 0}, {320, 53}} { PLCameraButton {{110, 6}, {100, 41}} { UIView {{37, 10}, {26, 21}} { UIImageView {{0, 0}, {26, 21}} } } PLCropOverlayBottomBarButton {{6, 8.5}, {70, 41}} { UIImageView {{0, 0}, {70, 41}} UIButtonLabel {{15, 10.5}, {40, 15}} } } } } } } } }
The function I use to detact view's layout:
-(void)detactSubview:(UIView *)view layer:(int)layer buffer:(NSMutableString*)buffer{ NSMutableString *s = [[NSMutableString alloc] init]; for (int i=0; i<layer; i++) { [s appendString:@"\t"]; } NSString *sName = NSStringFromClass([view class]); [buffer appendFormat:@"%@%@ %@\n",s,sName, NSStringFromCGRect(view.frame)]; if(view.subviews.count>0){ [buffer appendFormat:@"%@{\n",s]; layer++; for(UIView *subView in view.subviews){ [self detactSubview:subView layer:layer buffer:buffer]; } [buffer appendFormat:@"%@}\n",s]; } }
I find that "PLPreviewOverlayView" and "PLCropOverlay" is the layer I want to hide.
/* PLCropOverlay : capture panel PLPreviewOverlayView: control panel */ view = ((UIViewController*)[imagePickerController.viewControllers objectAtIndex:0]).view; NSLog(@"%@",view.subviews); for (UIView *subview in view.subviews) { NSLog(@"sub2:%@", subview); if([NSStringFromClass([subview class]) isEqualToString:@"PLPreviewOverlayView"] || [NSStringFromClass([subview class]) isEqualToString:@"PLCropOverlay"]){ subview.hidden = YES; // [subview removeFromSuperview]; NSLog(@"******************** hide"); } }
Using the code above can resolve the singular matrix error.