ios - 返回并按下 UIAlertview 按钮时应用程序崩溃

标签 ios objective-c memory-management crash uiresponder

我有自己的聊天窗口,类似于 Apple Messaging 屏幕。有一种情况是,我正在群聊中聊天,群组所有者从其他设备上删除了该群组。在这种情况下我要做的是删除所有消息并显示执行 [self.navigationController popToRootViewControllerAnimated:YES]; 并在下一行我显示这样的警报 View

 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Group deleted"  message:@"The group is deleted" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];

现在,如果我在导航回 rootViewController 时抬起键盘并在 UIAlertview 中按“确定”,那么神奇的事情就会发生,然后应用程序崩溃,并在控制台中显示以下错误 [ResponderView _responderWindow]:消息发送到已释放的实例 0x16312440 并在分析僵尸工具中一条 Objective-C 消息已发送到地址为 0x18a89aa0` 的已释放的“ResponderView”对象(僵尸),并且回溯是一些东西像这样

thread #1: tid = 0x1aa279, 0x2abf5272 CoreFoundation`___forwarding___ + 534, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)
  * frame #0: 0x2abf5272 CoreFoundation`___forwarding___ + 534
    frame #1: 0x2ab24e78 CoreFoundation`_CF_forwarding_prep_0 + 24
    frame #2: 0x2e26a728 UIKit`-[UIView(Internal) _firstResponder] + 20
    frame #3: 0x2e26a708 UIKit`-[UIResponder isFirstResponder] + 24
    frame #4: 0x2e9075a8 UIKit`-[UITextView _keyboardDidShow:] + 24
    frame #5: 0x2aba9e08 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #6: 0x2ab04514 CoreFoundation`_CFXNotificationPost + 1784
    frame #7: 0x2b866748 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 72
    frame #8: 0x2e8d4706 UIKit`-[UIInputWindowController postEndNotifications:withInfo:] + 554
    frame #9: 0x2e8d55dc UIKit`-[UIInputWindowController mergeTransitionIfNecessaryWithTransition:] + 244
    frame #10: 0x2e8d575c UIKit`-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 92
    frame #11: 0x2e8d9410 UIKit`-[UIInputWindowController setPlacement:starting:completion:] + 48
    frame #12: 0x2e8d9004 UIKit`-[UIInputWindowController setInputViewSet:] + 624
    frame #13: 0x2e8d54ce UIKit`-[UIInputWindowController performOperations:withAnimationStyle:] + 38
    frame #14: 0x2e324f40 UIKit`-[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1012
    frame #15: 0x2e341b86 UIKit`-[UIPeripheralHost(UIKitInternal) _restoreInputViewsWithId:animated:] + 590
    frame #16: 0x2e604b6e UIKit`-[UIAlertController _restoreInputViewsAnimated:] + 114
    frame #17: 0x2e60496c UIKit`-[UIAlertController viewDidDisappear:] + 76
    frame #18: 0x2e2846c0 UIKit`-[UIViewController _setViewAppearState:isAnimating:] + 364
    frame #19: 0x2e284c12 UIKit`-[UIViewController _endAppearanceTransition:] + 290
    frame #20: 0x2e543eb2 UIKit`-[UIPresentationController transitionDidFinish:] + 862
    frame #21: 0x2e546172 UIKit`__56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 150
    frame #22: 0x2e37f31e UIKit`-[_UIViewControllerTransitionContext completeTransition:] + 102
    frame #23: 0x2e2a2cc0 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 308
    frame #24: 0x2e2a28dc UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 184
    frame #25: 0x2e2a27ee UIKit`-[UIViewAnimationState animationDidStop:finished:] + 66
    frame #26: 0x2dc86960 QuartzCore`CA::Layer::run_animation_callbacks(void*) + 236
    frame #27: 0x0150915e libdispatch.dylib`_dispatch_client_callout + 22
    frame #28: 0x0150ce44 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1512
    frame #29: 0x2abb7608 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
    frame #30: 0x2abb5d08 CoreFoundation`__CFRunLoopRun + 1512
    frame #31: 0x2ab02200 CoreFoundation`CFRunLoopRunSpecific + 476
    frame #32: 0x2ab02012 CoreFoundation`CFRunLoopRunInMode + 106
    frame #33: 0x325d3200 GraphicsServices`GSEventRunModal + 136
    frame #34: 0x2e2cea08 UIKit`UIApplicationMain + 1440
    frame #35: 0x000faeec JonglaIM`main(argc=9, argv=0x0129e9b4) + 108 at main.m:16

如果键盘按下,然后我 popToRootViewController 然后单击 UIAlertBox OK 按钮,则不会发生这种情况

最佳答案

您是否尝试过在后退操作时以编程方式隐藏键盘?可能是键盘问题,我认为警报将键盘保留在屏幕上,而通常情况下它应该隐藏。

关于ios - 返回并按下 UIAlertview 按钮时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32135136/

相关文章:

ios - 如何将 AFOAuth1Client 与 AFIncrementalStore 一起使用

objective-c - 具有不透明背景的 CALayer 中的文本抗锯齿

asp.net - Environment.WorkingSet错误

ios - Spritekit 中的新场景没有显示任何内容?

android - 为 iPad 或 Android 教育应用程序进行高级 2D 图形开发? (处理?rokon?)

objective-c - NSUInteger 相当于普通的旧 int 吗?

c - 使用 malloc 时触发异常

ios - 导出为 ipa 后设备 token 发生变化

ios - 获取精确的日期和时间值

c++ - 如何保证进程调用malloc()时立即分配物理内存?