如何确定用户是否已滚动到UITableView的底部? [英] How to determine if the user has scrolled to the bottom of the UITableView?

查看:114
本文介绍了如何确定用户是否已滚动到UITableView的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定用户是否已滚动到UITableView的最后一个单元格/底部?

How can I determine if the user has scrolled to the last cell/bottom of a UITableView?

推荐答案

UITableView继承自UIScrollView和滚动视图公开了 contentOffset 属性(文档此处)。

UITableView inherits from UIScrollView, and scroll view exposes a contentOffset property (documentation here).

将此用于一些数学来确定contentOffset是否在底部的 frame.size.height 之内。

Use this with a bit of math to determine if the contentOffset is within frame.size.height of the bottom.

更新:这里是一个公式,可以给你你想要的东西:

Update: here's a stab at a formula that will give you what you want:

if(tableView.contentOffset.y >= (tableView.contentSize.height - tableView.frame.size.height)) {
  //user has scrolled to the bottom
}

这篇关于如何确定用户是否已滚动到UITableView的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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