Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding layoutSubViews: causes "CGAffineTransformInvert: singular matrix" randomly

I'm overriding layoutSubViews: in a UIScrollView and from time to time I get "CGAffineTransformInvert: singular matrix" for every subview I reposition. The layout looks totally okay however. The app does not crash either.

Does anybody know what causes this?

like image 508
Krumelur Avatar asked Sep 19 '11 12:09

Krumelur


3 Answers

I once had this error cause by mistake was setting a font with size 0 when using

[UIFont fontWithName:size:] 

for a UILabel.

like image 85
Fede Mika Avatar answered Nov 08 '22 18:11

Fede Mika


In case anyone else is struggling with this (and in case it's not because of setting the label font size to 0), "CGAffineTransformInvert: singular matrix" seems to come up when layoutSubViews: runs on a view (such as UIScrollView or UILabel) that has a frame of size (0,0).

Took me forever to figure out because if your container view (e.g. the scroll view) is not set up to clip subviews, the layout will still look fine.

like image 16
Laura Avatar answered Nov 08 '22 17:11

Laura


I was seeing this problem too when I added a UIWebView to my self.view.

The offending code was:

UIWebView *wv = [[UIWebView alloc]init];

and the solution is:

UIWebView *wv = [[UIWebView alloc]initwithFrame:[[UIScreen mainScreen]bounds]];

or any framesize except 0.0.

like image 4
zyzzyxx Avatar answered Nov 08 '22 18:11

zyzzyxx