今天碰到一个iOS crash,记录一下
*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010e4a4c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010dd81bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010e4a4b9d +[NSException raise:format:] + 205
3 QuartzCore 0x000000010ab52346 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 152
4 QuartzCore 0x000000010ab524b8 -[CALayer setPosition:] + 43
5 QuartzCore 0x000000010ab52b77 -[CALayer setFrame:] + 720
6 UIKit 0x000000010aed2f9d -[UIView(Geometry) setFrame:] + 356
7 UIKit 0x000000010afe5784 -[UIImageView _setViewGeometry:forMetric:] + 252
这崩溃的提示,就是在有些view.frame 的地方计算的时候,进行了除0或者是返回了无穷大;找到计算的位置,然后根据自己业务的需求,进行修改即可。