简体   繁体   中英

App crashes when navigating back and UIAlertview button is pressed

I have my own chat window similar to like Apple Messaging screen. There is a scenario that i am chatting in a groupchat and the group owner deletes the group from some other device. What i do in that case is i remove all the messages and show do a [self.navigationController popToRootViewControllerAnimated:YES]; and on the next line i show a alertview like this

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

Now the magic happens if i have my keyboard up when i navigated back to rootViewController and press OK in the UIAlertview then app crashes with the following error in console [ResponderView _responderWindow]: message sent to deallocated instance 0x16312440 and in the profiling zombie tool An Objective-C message was sent to a deallocated 'ResponderView' object (zombie) at address: 0x18a89aa0` and the backtrace is some thing like this

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

This does not happen if the keyboard is down and then i popToRootViewController and then click on the UIAlertBox OK button

Have you tried to hide keyboard programmatically on back action? Probably it's the keyboard issue, I think that alert keeps the keyboard on the screen, when normally it should be hidden.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM