Tell if UITableView has scrolled to top

When the table view goes under navigation bar and safe area layout guides are enabled, the following check can be done:

if (tableView.contentOffset.y + tableView.safeAreaInsets.top) == 0 { ... }

Bonus: Check for contentSize if you want to avoid getting 0 before the content is load:

if tableView.contentSize.height > 0 && 
    ((tableView.contentOffset.y + tableView.safeAreaInsets.top) == 0) { ... }

The scrollViewDidScrollToTop: method fires when the user clicks on the status bar and the scrollsToTop property is set to YES. From the docs:

The scroll view sends this message when it finishes scrolling to the top of the content. It might call it immediately if the top of the content is already shown. For the scroll-to-top gesture (a tap on the status bar) to be effective, the scrollsToTop property of the UIScrollView must be set to YES.

It does not fire if the user manually scrolls to the top. If you want to handle this case you will have to implement the scrollViewDidScroll: method and check to see whether the scroll is at the top yourself.

You can check this through the contentOffset property e.g.:

if (scrollView.contentOffset.y == 0) { // TOP }