I am getting the following crash:
CALayerInvalidGeometry CALayerInvalidGeometry
CALayer bounds contains NaN: [nan 0; nan 15.1]
on the last line of this code:
CGRect bounds = self.bounds;
bounds.size = CGSizeMake(fabsf(self.width), self.height);
self.bounds = bounds;
where self.width is derived from a pan gesture recognizer:
CGPoint panGestureRecognizerTranslationPoint = [panGestureRecognizer translationInView:panGestureRecognizer.view.superview.superview];
CGPoint rotatedPanGestureRecognizerTranslationPoint = CGPointApplyAffineTransform(panGestureRecognizerTranslationPoint, CGAffineTransformMakeRotation(-self.angle));
self.width += rotatedPanGestureRecognizerTranslationPoint.x;
The one commonality when I get this crash is in the error message, it's always [nan 0; followed by something. Anyone know what could be causing this?
in my case I forgot to add images in my project and runtime I was trying to use those images by their name thats why I got this error.
Now its solved after placed the images in project.
Hope this tips helps to others.
[nan 0; nan 15.1]
This means that the x
position of the bounds and the width
are both not numbers. That could mean negative values, or it could be a divide by zero type issue. nan
of the width could also possibly be a very large width that can't be supported (though that should lead to other error messages).
This kind of thing will often be the result of transforms being applied, either to the values used to create the bounds
or to the view / layer to which the bounds are applied (as this will modify the applied bounds
to determine the frame
).
With rotation transforms, be careful with the anchorPoint
.
When using view / layer transforms, reset the transform to identity
before making changes to the frame
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With