简体   繁体   English

UITableView 在设备旋转后保持滚动 position

[英]UITableView maintain scroll position after device rotation

How do we maintain current scrolling position in a table view when device is rotated?当设备旋转时,我们如何在表格视图中保持当前滚动 position?

I've tried this solution but it doesn't work https://stackoverflow.com/a/39779728/12114641我已经尝试过这个解决方案,但它不起作用https://stackoverflow.com/a/39779728/12114641

There is no inbuilt fix.没有内置修复程序。 You have to save the scroll position (row) before rotation and then scroll to that row after rotation.您必须在旋转前保存滚动 position(行),然后在旋转后滚动到该行。

In viewWillLayoutSubviews save row and in viewDidLayoutSubviews call scroll to the saved row.viewWillLayoutSubviews保存行并在viewDidLayoutSubviews调用滚动到保存的行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM