Search code examples
iosswiftipados

iPadOS UIToolbar wrong place after rotation


I'm adding a UIToolbar in top of the keyboard using inputAccesoryView:

let toolbar = UIToolbar()
toolbar.barStyle = .default
toolbar.isTranslucent = true
toolbar.sizeToFit()
toolbar.isUserInteractionEnabled = true

...

textField.inputAccessoryView = toolbar

But when I hide the keyobard, rotate the device, the next time I open the keyboard, sometimes it shows the UIToolbar in the middle of the screen:

enter image description here

But the next time I open the keyboard, the UIToolbar it shows in the right place.

I don't know if it is an iPadOS bug. Any ideas how can I solve this? I'm using an UITableViewController to populate table with cells and text fields.


Solution

  • I was able to solve the issue unchecking the Upside down orientation:

    enter image description here