danielamitay / DAKeyboardControl

DAKeyboardControl adds keyboard awareness and scrolling dismissal (ala iMessages app) to any view with only 1 line of code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory Issue

erudenko opened this issue · comments

After application logout, I recreate all UI stack from storyboard:

UIViewController *viewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
self.window.rootViewController = viewController;

And after that all TextViews and inputFields crashed application.
Sometimes they just EXT_BAD_ACCESS, but sometimes this backlog.
It's looks like DAKeyboardControl handles references for zombies, and sometimes instead of zombies it's just trash, sometimes new objects (like __NSCFType here).

-[__NSCFType responderDidBecomeActive:]: unrecognized selector sent to instance 0x10b2a5430
2014-08-23 13:20:11.575 Hello[97049:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType responderDidBecomeActive:]: unrecognized selector sent to instance 0x10b2a5430'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103769495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010331299e objc_exception_throw + 43
    2   CoreFoundation                      0x00000001037fa65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010375ad8d ___forwarding___ + 973
    4   CoreFoundation                      0x000000010375a938 _CF_forwarding_prep_0 + 120
    5   CoreFoundation                      0x00000001037bed9c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    6   CoreFoundation                      0x000000010372151d _CFXNotificationPost + 2381
    7   Foundation                          0x00000001012217fa -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
    8   UIKit                               0x0000000102463256 -[UITextField _becomeFirstResponder] + 521
    9   UIKit                               0x0000000101f5903c -[UIResponder becomeFirstResponder] + 340
    10  UIKit                               0x0000000101e79673 -[UIView(Hierarchy) becomeFirstResponder] + 99
    11  UIKit                               0x0000000102462b08 -[UITextField becomeFirstResponder] + 51
    12  UIKit                               0x0000000102155d01 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 187
    13  UIKit                               0x0000000102157b30 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1768
    14  UIKit                               0x000000010214dfc2 _UIGestureRecognizerSendActions + 188
    15  UIKit                               0x000000010214cf28 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 357
    16  UIKit                               0x00000001021512d9 ___UIGestureRecognizerUpdate_block_invoke + 53
    17  UIKit                               0x0000000102151261 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 257
    18  UIKit                               0x0000000102149337 _UIGestureRecognizerUpdate + 93
    19  UIKit                               0x0000000101e5da15 -[UIWindow _sendGesturesForEvent:] + 928
    20  UIKit                               0x0000000101e5e6d4 -[UIWindow sendEvent:] + 909
    21  UIKit                               0x0000000101e3629a -[UIApplication sendEvent:] + 211
    22  UIKit                               0x0000000101e23aed _UIApplicationHandleEventQueue + 9579
    23  CoreFoundation                      0x00000001036f8d21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x00000001036f85f2 __CFRunLoopDoSources0 + 242
    25  CoreFoundation                      0x000000010371446f __CFRunLoopRun + 767
    26  CoreFoundation                      0x0000000103713d83 CFRunLoopRunSpecific + 467
    27  GraphicsServices                    0x0000000104475f04 GSEventRunModal + 161
    28  UIKit                               0x0000000101e25e33 UIApplicationMain + 1010
    29  Hello                               0x000000010007f663 main + 115
    30  libdyld.dylib                       0x0000000103d585fd start + 1

Handle it in dealloc:

- (void)dealloc 
{
    [self.view removeKeyboardControl];
}

Just FYI calling [self.view removeKeyboardControl]; in dealloc will cause the view to get instantiated again.