【问题标题】:App crashes when navigating back and UIAlertview button is pressed导航返回并按下 UIAlertview 按钮时应用程序崩溃
【发布时间】:2015-08-21 07:54:29
【问题描述】:

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

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

现在,如果我在导航回 rootViewController 并在 UIAlertview 中按 OK 时打开键盘,然后应用程序在控制台 [ResponderView _responderWindow]: message sent to deallocated instance 0x16312440 和分析僵尸工具 An Objective-C message was sent to a deallocated 'ResponderView' object(僵尸) 在地址:0x18a89aa0` 和回溯是这样的

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 objective-c memory-management crash uiresponder


    【解决方案1】:

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

    【讨论】:

    • 您的意思是在显示警报和导航返回之前尝试调用 reisgnFirstResponder?
    猜你喜欢
    • 1970-01-01
    • 2011-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多