1

I have a table setup like so:

view.addSubview(tableView)
tableView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
    tableView.topAnchor.constraint(equalTo: view.topAnchor),
    tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
    tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
    tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
])

I log the content offset:

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    print(scrollView.contentOffset.y)
}

why is the value -20.0? Is it possible to set it to 0.0 ?

Kex
  • 8,023
  • 9
  • 56
  • 129
  • Do you mean bouncing during scroll out of edge? The just disable it `tableView.bounces = false`. – Asperi Dec 07 '20 at 10:10
  • I guess your tableView seted contentInset.top is 20 – vinsent Dec 07 '20 at 10:27
  • There is a similar question answered here https://stackoverflow.com/questions/48319873/uiscrollview-resting-at-incorrect-contentoffset-20-px-not-0px It looks like your table view content is going beneath the status bar which height is 20pt or 44pt on iPhones with the notch. – Yulian Baranetskyy Dec 07 '20 at 10:40

0 Answers0