0

I have a problem that I couldn't find any appropriate solution. I have a tableView with custom cells which holds a textView inside. also I have a blank grey footer for the section. whenever I click on the textView and the keyboard pops up the footer in that section goes up and hides behind the textView field.

I don't know how to make that footer sticky so it won't move when the keyboard pops. if anyone have a solution it will be great! thank you!

    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    if section == 0 {
        let footerView = UIView()
        footerView.backgroundColor = .red
            return footerView
    }else {
        return UIView()
    }
}

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
    return 8
}
  • 1
    I noticed 2 solutions from here: https://stackoverflow.com/questions/5740518/uitableview-footer-stop-from-floating-over-content - One is to set the UITableView style as grouped and the other is to not use section footers but create one additional cell in each section which should be customized as your footer. – Shawn Frank Jan 20 '22 at 13:47

1 Answers1

0

Set your tableView as grouped give height to the tableview footer and tableView Header in the tableview header,footer height functions.

If you are not using tableview header the set the height of the header to .leastNormalMagnitude .

This is the way to make the tableView Footer Static.