Tien Nguyen Tien Nguyen - 9 months ago 59
Swift Question

UITextView's not displaying content during push animation when is in inputAccessoryView

I have

that has
overrided with custom
, lets call that view controller A. And I have another view controller that push A to navigation stack.

So, when I push A first time everything is ok - the
appeared with text immediately. The strange thing starts with next push - the
's text does not appear until view controller push transition animation end.

During animation =>
Animation completed

The code of viewController A is there:

class NextViewController: UIViewController {

private var userInputView: UIView!

override func viewDidLoad() {
view.backgroundColor = UIColor.grayColor()

let textView = UITextView(frame: CGRect(origin: .zero,
size: CGSize(width: 200, height: 30)
), textContainer: nil)
textView.text = "asd"

userInputView = textView

override var inputAccessoryView: UIView? {
return userInputView

override func canBecomeFirstResponder() -> Bool {
return true


Tested in iOS 9.3 simulator.

After some coding I noticed that if
is not deallocated (stored somewhere in global scope) the appearance during animation is defined by last
state. But this solution is not good for me
is ok actually. But is there any native-like solution, am I missing something? Because the desired behaviour is rather standard in my opinion.

Answer Source

So I will stick with the solution where the inputAccessoryView is stored until next appearance.