iOS TableView reload and scroll top : <p>the second day I can not solve the problem with the table.</p>

<p>We have a segmentedControl which, when changed, changes the table.
Suppose that there are 3 elements in the segment of the control and, correspondingly, 3 arrays (which is important, they are of different sizes)
I need to scroll table up when segmentedControl is changed.</p>

<p>And it seems like everything is simple: contentOffset = .zero and reloadData ()</p>

<p>But. This does not work, I do not know why the table not scroll up.</p>

<p>The only thing that worked:</p>

<pre><code>UIView.animate (withDuration: 0.1, animations: {
            self.tableView.contentOffset = .zero
        }) {(_) in
            self.tableView.reloadData ()
}
</code></pre>

<p>But now there is another problem when the table goes up, a bug may occur, because the segmentedControl has changed, and the data in the other array may not be, we have not yet done reloadData ()</p>

<p>Maybe I can not understand the obvious things)) Congrats on the upcoming holidays!</p>
