开发者

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 subvi开发者_StackOverflow社区ew I reposition. The layout looks totally okay however. The app does not crash either.

Does anybody know what causes this?


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

[UIFont fontWithName:size:] 

for a UILabel.


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.


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.


In my application I got this error as I forget to call the -layoutSubViews of the superClass in the overridden -layoutSubViews method,

so make a call [super layoutSubViews] at any point in your overridden method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜