I am developing a book application in which users can change the font size in a TextView.
when users change the font size, the application saves the current position of the text so as not to change it after users have changed the font size.
It works fine in most cases, but sometimes when users change the font size, the application gets this error, and I still canβt figure out how to fix it.
Application Completion due uncaught exception "CALayerInvalidGeometry", cause: "CALayer bounds comprises NaN: [0 nan; 280524] '* Origin call stack cast: (0x3231e3e7 0x3a019963 0x3231e307 0x33edb4d7 0x33edb30d 0x3419141f 0x3419b82f 0x342d1cf1 0x3414f80d 0xe7bf1 0xe607d 0xfad35 0x34218087 0x34218111 0x34218087 0x34218015 0x3421803b 0x342178cb 0x34217db9 0x341405f9 0x3412d8e1 0x3412d1ef 0x35e455f7 0x35e45227 0x322f33e7 0x322f338b 0x322f220f 0x3226523d 0x3226bfbf0fbf23
I also cannot reproduce this problem 100%, as this problem sometimes happens.
This is the code. Anyone have an idea to fix this? Thanks in advance.
- (UITextRange *)getCurrentTextRange:(UITextView *)textView { CGRect bounds = textView.bounds; UITextPosition *start = [textView characterRangeAtPoint:bounds.origin].start; UITextPosition *end = [textView positionFromPosition:start offset:1]; UITextRange *textRange = [textView textRangeFromPosition:start toPosition:end]; return textRange; } - (void)changeFontSize:(UIButton*)button { UITextRange *textRange = [self getCurrentTextRange:_textView]; int fontSize = [[NSUserDefaults standardUserDefaults] integerForKey:@"fontSize"];
ios iphone calayer crash
Non umemoto
source share