Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [0 nan; 280 524]'

后端 未结 2 1067
说谎
说谎 2021-01-17 11:33

I am developing a book app where users can change the font size on the TextView.

when users change the font size, the app save the current text position not to chang

相关标签:
2条回答
  • 2021-01-17 11:40

    In my case, code was doing 0.0 / 0.0 resulting -nan (infinity) and used further for converting to double.

    I added a guard condition to make sure values are > 0.0

    0 讨论(0)
  • 2021-01-17 11:50

    Somewhere along the line here, you are getting an invalid output that is causing rect to have the value NaN (a special float value meaning "not a valid float number", most commonly caused by division by zero). Is it possible that you have passed an invalid or nonsensical UITextRange to -firstRectForRange? What happens if UITextPosition *start references the last character in the text, when you then create another text position that is one character past the end?

    0 讨论(0)
提交回复
热议问题