0

I have some weird UI bug with inputAccessoryView and keyboard. Code to add inputAccessoryView in viewDidLoad

        let keyboardToolbar = UIToolbar()
    keyboardToolbar.items = [
        UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
        UIBarButtonItem(title: "Hide", style: .done, target: self, action: #selector(resignFirstResponder))
    ]

    keyboardToolbar.barStyle = barStyle
    keyboardToolbar.sizeToFit()

    myTextfield.inputAccessoryView = keyboardToolbar

First time entering screen and tap to textfield works good. After closing this screen (popViewController) and entering it again and get focus to textField I've got this: UIToolBar is above keyboard. Empty space have height = keyboard height

ui bug image

B2Fq
  • 876
  • 1
  • 8
  • 23

2 Answers2

0

this because there is safe area in IOS 11 and this space appear on iphone X

Check this post may be duplicated

iPhone X how to handle View Controller inputAccessoryView?

Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35
0

I do not know the reason but workaround is to call either

view.endEditing

or

textField.resignFirstResponder()

in

viewWillDisappear