UITableView:当显示tableFooterView时运行代码? [英] UITableView: Run code when tableFooterView is displayed?

查看:94
本文介绍了UITableView:当显示tableFooterView时运行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIView tableFooterView 会在表格底部显示一个正在加载更多标签。当显示 tableFooterView 中的UIView时,我需要开始一些延迟下载内容。如何知道何时显示tableFooterView?

I'm using the UIView tableFooterView of in my UITableView to show a "Loading more" label at the bottom of my table. When the UIView in tableFooterView is shown, I need to start some lazy download of content. How do I know when the tableFooterView is displayed?

推荐答案

/ strong>检查正在请求表的最后一行,然后加载数据。用户滚动到最后一行而不向下滚动以查看页脚的次数可能是非常少的。效果将是一样的,即你知道用户何时滚动到底部,你应该加载更多的数据。

Instead of determining when the footer view will show you could check when the last row of the table is being requested and load the data then. The number of times a user scrolls to the very last row without scrolling down to see the footer are probably very few. The effect will be the same, i.e. you know when the user has scrolled to the bottom and you should load more data.

这可以很容易地在 tableView:cellForRowAtIndexPath:。通过跟踪IndexPath是最后一个,并在每次添加或删除新行时更新它,您可以简单地检查所请求单元格的IndexPath是否与最后一行的IndexPath相同,并触发延迟加载更多的数据从那里,以同样的方式,你目前做的。

This can quite easily be implemented in tableView:cellForRowAtIndexPath:. By keeping track of what IndexPath is the last one, and updating it every time new rows are added or deleted, you can simply check if the IndexPath of the requested cell is the same as the IndexPath of the last row and trigger the lazy loading of more data from there, the same way you are currently doing it.

这篇关于UITableView:当显示tableFooterView时运行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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