Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当使用shake撤消粘贴到UITextView时,iOS超出范围崩溃,覆盖了ShouldChangeCharactersRange_Ios_Crash Reports - Fatal编程技术网

当使用shake撤消粘贴到UITextView时,iOS超出范围崩溃,覆盖了ShouldChangeCharactersRange

当使用shake撤消粘贴到UITextView时,iOS超出范围崩溃,覆盖了ShouldChangeCharactersRange,ios,crash-reports,Ios,Crash Reports,我的iOS应用程序崩溃了,我有崩溃报告,但我无法找出崩溃的原因。 奇怪的是,这个崩溃发生在应用程序启动后不久,在崩溃报告中没有显示我的代码: Thread 0 Crashed: 0 CoreFoundation 0x00000002069d0ea4 __exceptionPreprocess + 228 1 libobjc.A.dylib 0x0000000205ba0a50 objc_exception_throw +

我的iOS应用程序崩溃了,我有崩溃报告,但我无法找出崩溃的原因。 奇怪的是,这个崩溃发生在应用程序启动后不久,在崩溃报告中没有显示我的代码:

Thread 0 Crashed:
0   CoreFoundation                  0x00000002069d0ea4 __exceptionPreprocess + 228
1   libobjc.A.dylib                 0x0000000205ba0a50 objc_exception_throw + 56
2   CoreFoundation                  0x00000002068d7484 -[NSCache init] + 0
3   Foundation                      0x0000000207355b94 -[NSString substringWithRange:] + 140
4   UIKitCore                       0x00000002331cd8b8 -[NSTextStorage+ 12540088 (UIKitUndoExtensions) _undoRedoAttributedSubstringFromRange:] + 152
5   UIKitCore                       0x00000002331ce808 -[_UITextUndoOperationTyping undoRedo] + 340
6   Foundation                      0x00000002073f6734 -[_NSUndoStack popAndInvoke] + 280
7   Foundation                      0x00000002073f4790 -[NSUndoManager undoNestedGroup] + 416
8   UIKitCore                       0x0000000232ed1824 __58-[UIApplication _showEditAlertViewWithUndoManager:window:]_block_invoke.2529 + 32
9   UIKitCore                       0x0000000232618a58 -[UIAlertController _invokeHandlersForAction:] + 108
10  UIKitCore                       0x000000023261941c __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissCompletion:]_block_invoke.477 + 28
11  UIKitCore                       0x0000000232821784 -[UIPresentationController transitionDidFinish:] + 1320
12  UIKitCore                       0x0000000232825794 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.440 + 188
13  UIKitCore                       0x0000000232923714 -[_UIViewControllerTransitionContext completeTransition:] + 116
14  UIKitCore                       0x000000023335cc4c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 744
15  UIKitCore                       0x00000002333328f0 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
16  UIKitCore                       0x0000000233332edc -[UIViewAnimationState animationDidStop:finished:] + 296
17  UIKitCore                       0x0000000233332f7c -[UIViewAnimationState animationDidStop:finished:] + 456
18  QuartzCore                      0x000000020afde500 CA::Layer::run_animation_callbacks+ 1381632 (void*) + 284
19  libdispatch.dylib               0x0000000206409484 _dispatch_client_callout + 16
20  libdispatch.dylib               0x00000002063b59a4 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068
21  CoreFoundation                  0x0000000206960ce4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
22  CoreFoundation                  0x000000020695bbac __CFRunLoopRun + 1964
23  CoreFoundation                  0x000000020695b0e0 CFRunLoopRunSpecific + 436
24  GraphicsServices                0x0000000208bd4584 GSEventRunModal + 100
25  UIKitCore                       0x0000000232ec0c00 UIApplicationMain + 212
26  MyApplication                   0x00000001009489fc main (main.m:17)
27  libdyld.dylib                   0x0000000206419bb4 start + 4
复制步骤:

  • 使用
    UITextField
  • 执行
    UITextField委托
    协议并分配
    UITextField委托
  • 实现
    -(BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string
    方法,从该方法返回否 方法
  • 运行应用程序并尝试将文本粘贴到
    UITextField
    中,并观察到实际上没有粘贴任何文本
  • 摇动手机可触发撤销提示
  • 轻触提示符中的“撤消”按钮,观察碰撞

如果
UITextView
UITextField
的文本在更改过程中以编程方式更改,则将非常感谢您的帮助。撤消管理器将不会更新,并将跟踪错误操作。 为了避免崩溃,我们应该重置撤消管理器,使其不包含脏操作

[textField.undoManager removeAllActions];

你能发布appDelegate和first controller的sour文件吗?不幸的是,我不是。但我添加了复制崩溃的步骤。