UIViewController with inputAccessoryView is not deallocated

前端 未结 2 2106
-上瘾入骨i
-上瘾入骨i 2021-02-06 03:41

I have simple subclass of UIViewController (code below). If I attach inputAccessoryView, my viewcontroller is never deallocated. If I do not set inputAccessoryView in viewDidLo

2条回答
  •  不要未来只要你来
    2021-02-06 04:24

    Unfortunately for me @rdelmar's answer didn't work. After some time spent trying to solve it I found this article: http://derpturkey.com/uitextfield-docked-like-ios-messenger/

    My goal is to have the input accessory view visible even if the keyboard is not, exactly like in all IM apps. I previously subclassed my UIViewController custom class to allow it to become first responder and returned my custom subview as inputAccessoryView. This was preventing the view controller from being dealloced. Now I subclass the controller's view to achieve the same thing as recommended in the link above, everything seems to work fine.

    EDIT: after some more testing I can confirm the custom UIView is dealloced just fine.

    EDIT 2: only downside is that you can't make the keyboard appear in viewWillAppear, the inputAccessoryView is not already added to the view hierarchy and can't become first responder.

提交回复
热议问题