你将如何实现一个UITableView检测水平滑动以允许分页? [英] How would you implement an UITableView that detects horizontal swipes in order to allow paging?

查看:91
本文介绍了你将如何实现一个UITableView检测水平滑动以允许分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个UITableView,一次显示20行。但是考虑到我可能会说120个项目,我想使用某种分页处理这个:

I'd like to implement a UITableView which displays say 20 rows at a time. But given the fact that I might actually have say 120 items to present, I'd like to handle this using some sort of paging:

填充前20个项目。当用户执行从右向左滑动,重新加载UITableView与下20个项目。从左到右滑动将显示前面的20个项目。

Populate table with first 20 items. When the user does a right-to-left swipe, reload the UITableView with the next 20 items. A left-to-right swipe would show the previous 20 items.

我认为子类化UITableView和处理UITouches有方法去,但我不知道以正确地处理触摸,以便不干扰标准事件处理。

I think subclassing UITableView and handle UITouches there is the way to go, but I'm not sure how to handle the touches correctly in order not to interfer with the standard event handling.

例如。如果用户只触摸(点击)一行,我想要该行高亮(选择),然后切换到呈现对应于所选行的数据的详细视图。但是如果用户进行水平滑动,我不想让滑动下面的行突出显示(因此被选中),而是我想触发我的loadprevious页面/ loadnext页面处理,这将重新加载表, 20个上一个或下一个项目,具体取决于滑动方向。

Eg. if the user just touches (clicks) a row, I want the row to hightlight (selected) and then switch to a detail view presenting data corresponding to the selected row. But if the user does a horizontal swipe, I don't want the row below the swipe to be highlighted (and therefore selected), instead, i want to trigger my loadprevious page / loadnext page handling, which wil reload the table with the according 20 previous or next items, depending on the swipe direction.

有任何建议吗?

推荐答案

已经是导致该行被删除的标准UI行为。不要改变标准UI范例 - 它会让用户感到困惑,并使他们不喜欢你的应用程序。

A horizontal swipe on a table row is already a standard UI behavior that causes that row to be deleted. Don't go changing standard UI paradigms -- it confuses users and makes them dislike your app.

这篇关于你将如何实现一个UITableView检测水平滑动以允许分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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