如何获取 UITableView 滚动位置以便保存? [英] How can I get the UITableView scroll position so I can save it?

查看:45
本文介绍了如何获取 UITableView 滚动位置以便保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以找出滚动窗口顶部的 UITableViewCell 吗?

Is there any way to find out which UITableViewCell is at the top of the scroll window?

我想获取当前的滚动位置,以便在应用退出时保存它.当应用启动时,我想滚动到它上次退出时的位置.

I'd like to get the current scroll position so that I can save it when the app exits. When the app gets started I want to scroll to the position it was at when it last exited.

推荐答案

您可以通过查看表格视图的 contentOffset 属性轻松获取表格视图的确切偏移量.对于垂直滚动,请看:

You can easily grab the exact offset of the table view by looking at its contentOffset property. For the vertical scroll, look at:

tableView.contentOffset.y;

这篇关于如何获取 UITableView 滚动位置以便保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆