How to maintain scroll position in table view after device rotation

On iPad when device is rotated, e.g. from portrait to landscape, tableview scroll position is lost. How do we maintain scroll position after device rotation?

Replies

This behavior is supposed to happen automatically. I would make sure that you're not modifying the contentOffset, contentInset, or calling scrollToRow(at:...) anywhere else in your code.
If you are in portrait mode and you are seeing 15th row at the bottom of screen, if you rotate it to landscape you will see 11th row at the bottom as there is less vertical space in landscape mode.

So how do we make sure that the 15th row is always at the bottom when device is rotated?