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

查看:81
本文介绍了如何获取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天全站免登陆