iOS16 Crash TextView CALayer bounds contains NaN

277 阅读1分钟

#0 Thread

CALayerInvalidGeometry

CALayer bounds contains NaN: [0 nan; 388 822]. Layer: <CALayer:0x28295c4a0; position = CGPoint (194 411); bounds = CGRect (0 0; 388 822); delegate = <UIScrollView: 0x159022000; frame = (0 0; 388 822); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x28203a220>; backgroundColor = UIExtendedSRGBColorSpace 1 1 1 1; layer = <CALayer: 0x28295c4a0>; contentOffset: {0, 0}; contentSize: {0, 823}; adjustedContentInset: {0, 0, 0, 0}>; sublayers = (<CALayer: 0x28295c720>, <CALayer: 0x28295e0c0>, <CALayer: 0x282952aa0>); masksToBounds = YES; allowsGroupOpacity = YES; backgroundColor = <CGColor 0x280a959e0> [<CGColorSpace 0x280a811a0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 1 1 1 )>

经查询: iOS 16 textView.selectedTextRange 返回有问题,导致在使用

(CGRect)caretRectForPosition:(UITextPosition *)position;

方法时返回的x,y都是 +inf