0

Working in Xcode 14.2, using UIKit

I have a static table view being used as an input form. It has three sections and the last section contains a UITextView constrained to the cell margins.

After the keyboard appears, if the text view in section 3 is selected or the view is manually scrolled at all, what seems to be an empty section footer (a light grey bar) appears at the top of the keyboard. It disappears when section 3 is fully visible.

keyboard + footer

This obscures the text view when editing it. Adding an offset (i.e. based on keyboard height) adds space between the keyboard and the grey bar - so I can't just adjust for it.

I don't have, want or need section footers in this view, but i can't isolate why this one is appearing.

I've got the the following code in viewDidLoad as a part of making the text view scale with the entered text, but it doesn't seem to be the issue as commenting them out doesn't remove the issue.

override func viewDidLoad() {
        super.viewDidLoad()
        
        notesTextView.delegate = self
        notesTextView.isScrollEnabled = false

Any help tracking this down much appreciated.

Phil
  • 49
  • 7
  • Take a look at `additionalSafeAreaInsets`. You need to add the keyboard height to the safe area.this will make the view height change accordingly. Check this [post](https://stackoverflow.com/q/45399178/2303865) – Leo Dabus Mar 26 '23 at 15:59
  • Thanks @LeoDabus - I'll have a look. Whenever I tried using content inserts it just put white space between the top of the keyboard and the mystery footer bar though. – Phil Mar 28 '23 at 18:26

1 Answers1

1

Found similar issue at UITableView Footer, Stop from floating over content

Looks like you have difficulties with sticking of section footer to the top of keyboard. But you have to have sections. If you don't need footer in this case you can minimalize it, i.e.:

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return .leastNonzeroMagnitude
}

But if you need a section footer and want to get rid of it's sticking, change your UITableView's style in Interface Builder to "Grouped".

Alehei
  • 26
  • 3