CGAffineTransformInvert: singular matrix.

这个错误叫奇异矩阵,不会引起崩溃,但是会打印一堆错误提示。
引起的原因可能会是以下六种:

  1. 字体的size设置为0
[UIFont fontWithName:@"AFontName" size:0] 
  1. 你添加的view控件frame为0 例如:
UIWebView *wv = [[UIWebView alloc]init];

解决:

UIWebView *wv = [[UIWebView alloc]initwithFrame:[[UIScreen mainScreen]bounds]];
  1. UIScrollView, storyboard , autolayout 冲突,这个好像是苹果的问题,解决方法是uncheck the "use autolayout" checkbox on storyboard properties
  2. 如果你用webview 载入网页出现这样问题的话,是因为CSS 设定 display: inline-block 而造成 Transform 错误 ( 估计是苹果的bug )
    解決方法是:
    选择一:不要用「display: inline-block」( Apple 应该回答你的解决方案)。
    选择二:如果使用「display: inline-block」是为了要把 Element 排成横的,那么你可以改用「display: table-cell」,效果一样!
  3. 可能是忘记调用下面方法
[super layoutSubViews]
  1. 如果尝试设置缩放比例为零,也会报该错误
[UIView animateWithDuration:0.5 animations:^{
     CGAffineTransform newTransform =  CGAffineTransformScale(myView, 0.0, 0.0);
     [myView setTransform:newTransform];
     } completion:^(BOOL finished) {
}];

改为接近0的一个数:

CGAffineTransform newTransform =  CGAffineTransformScale(s.transform, 0.0001f, 0.00001f);

参考

http://stackoverflow.com/questions/12015785/cgaffinetransforminvert-singular-matrix
http://stackoverflow.com/questions/7471027/overriding-layoutsubviews-causes-cgaffinetransforminvert-singular-matrix-ran

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容