OGeek|极客世界-中国程序员成长平台

标题: ios - 在iOS11上添加文本字段或点击textview崩溃 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:47
标题: ios - 在iOS11上添加文本字段或点击textview崩溃

我的项目在xcode 8中运行良好。但是在Xcode 9中,它在发布时崩溃了。将文本字段添加到情节提要或轻敲文本视图会导致崩溃。如果没有文本字段,则不会崩溃。我尝试更新pods并检查64位兼容性,删除旧字体文件,重新创建项目。这个项目有本地化。这可能是问题所在吗?

    Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFConstantString substringToIndex:]: Index 9223372036854775807 out of bounds; string length 8'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010a9b11cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010a30ff41 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010aa25b95 +[NSException raise:format:] + 197
    3   Foundation                          0x0000000109d02df7 -[NSString substringToIndex:] + 118
    4   UIKit                               0x000000010bfcfd6c _normalizedAnimationKey + 97
    5   UIKit                               0x000000010bfcf718 -[UIViewAnimationState _shouldAnimateAdditivelyForKeynLayer:forView:] + 128
    6   UIKit                               0x000000010bfd049d -[UIViewAnimationState actionForLayer:forKey:forView:] + 193
    7   UIKit                               0x000000010bffb6bb +[UIView(Animation) _defaultUIViewActionForLayer:forKey:] + 114
    8   UIKit                               0x000000010c939a22 -[UIView(UIKitManual) actionForLayer:forKey:] + 157
    9   QuartzCore                          0x000000010bd788c4 -[CALayer actionForKey:] + 104
    10  QuartzCore                          0x000000010bd7ea49 _ZN2CA5Layer12begin_changeEPNS_11TransactionEjP11objc_objectRS4_ + 169
    11  QuartzCore                          0x000000010bd86241 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 253
    12  QuartzCore                          0x000000010bd76c96 -[CALayer setPosition:] + 43
    13  UIKit                               0x000000010bfe83b3 -[UIView setCenter:] + 233
    14  UIKit                               0x000000010bff0f7c -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 1103
    15  UIKit                               0x000000010bff106c -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 125
    16  CoreFoundation                      0x000000010a93e297 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 487
    17  UIKit                               0x000000010bfefaf9 -[UIView(Geometry) resizeSubviewsWithOldSize:] + 165
    18  UIKit                               0x000000010ca9a98d -[UIView(AdditionalLayoutSupport) _is_layout] + 211
    19  UIKit                               0x000000010bff8d99 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 989
    20  UIKit                               0x000000010c00d551 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1331
    21  QuartzCore                          0x000000010bd7d4ba -[CALayer layoutSublayers] + 153
    22  QuartzCore                          0x000000010bd815a9 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
    23  UIKit                               0x000000010bff7e5f -[UIView(Hierarchy) layoutBelowIfNeeded] + 662
    24  UIKit                               0x000000010cb6fe4f -[UIInputSetHostView layoutIfNeeded] + 104
    25  UIKit                               0x000000010cb792d9 -[UIInputWindowController updateToPlacement:withNormalAnimationsAndNotifications:] + 137
    26  UIKit                               0x000000010cb784ad __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.1000 + 197
    27  UIKit                               0x000000010c0009ec +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:viewptions:factory:animations:start:animationStateGenerator:completion:] + 560
    28  UIKit                               0x000000010c000e3f +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delayptions:animations:start:completion:] + 116
    29  UIKit                               0x000000010cb77f81 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1558
    30  UIKit                               0x000000010cb8027f -[UIInputWindowController setInputViewSet:] + 1147
    31  UIKit                               0x000000010cb775c2 -[UIInputWindowController performOperations:withAnimationStyle:] + 50
    32  UIKit                               0x000000010c720aa2 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1081
    33  UIKit                               0x000000010c16a781 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 81
    34  UIKit                               0x000000010cbf35f0 -[UITextView becomeFirstResponder] + 735
    35  UIKit                               0x000000010c53cb2b -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 208
    36  UIKit                               0x000000010c50dde9 -[UITextGestureClusterSelection oneFingerTap:] + 3845
    37  UIKit                               0x000000010c52cb8b -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
    38  UIKit                               0x000000010c535a13 _UIGestureRecognizerSendTargetActions + 109
    39  UIKit                               0x000000010c5332be _UIGestureRecognizerSendActions + 307
    40  UIKit                               0x000000010c53252a -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 1002
    41  UIKit                               0x000000010c51788d _UIGestureEnvironmentUpdate + 1306
    42  UIKit                               0x000000010c517327 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
    43  UIKit                               0x000000010c5163d3 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 288
    44  UIKit                               0x000000010bfb645c -[UIWindow sendEvent:] + 4102
    45  UIKit                               0x000000010bf5b802 -[UIApplication sendEvent:] + 352
    46  UIKit                               0x000000010c88da50 __dispatchPreprocessedEventFromEventQueue + 2809
    47  UIKit                               0x000000010c8905b7 __handleEventQueueInternal + 5957
    48  CoreFoundation                      0x000000010a9542b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    49  CoreFoundation                      0x000000010a9f3d31 __CFRunLoopDoSource0 + 81
    50  CoreFoundation                      0x000000010a938c19 __CFRunLoopDoSources0 + 185
    51  CoreFoundation                      0x000000010a9381ff __CFRunLoopRun + 1279
    52  CoreFoundation                      0x000000010a937a89 CFRunLoopRunSpecific + 409
    53  GraphicsServices                    0x0000000110e169c6 GSEventRunModal + 62
    54  UIKit                               0x000000010bf3ed30 UIApplicationMain + 159
    55  iSpect                              0x00000001078e864f main + 111
    56  libdyld.dylib                       0x000000010e5d3d81 start + 1



Best Answer-推荐答案


首先添加异常断点,这样您可以找到确切的崩溃位置,如果不解决请共享代码。

关于ios - 在iOS11上添加文本字段或点击textview崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46441914/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) Powered by Discuz! X3.4