用动画过滤UITableViewCells - iPhone开发 [英] Filtering UITableViewCells with animation - iPhone Development

查看:147
本文介绍了用动画过滤UITableViewCells - iPhone开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这似乎很简单,但至今我无法找到解决方案。

基本上我有一个分段控制与两个选项。第一个是默认的(并在加载时自动显示),选中时显示表格视图中的所有行。第二个是限制显示行的过滤器。这与iPhone手机应用程序的最近选项卡中使用的过滤全部和错过调用的设置完全相同。



目前我从两个不同的数组中加载数据。问题是,当我交换数据时,没有动画表示行已被过滤。苹果公司已经在他们的电话应用程序中实现了这一点,但我看不出有这种做法。



也许每个单元格都需要删除并重新添加,这两个国家 - 或者可能将我希望隐藏的单元格的高度设置为0会获得相同的效果?有没有人有任何生产这种手风琴动画的经验?



我看了这里一些线索,但有一些问题滚动一些代码工作。有没有人执行过这个?如果是这样,你是如何得到它的工作?

解决方案您可以通过调用在您的表视图中使用 UITableViewRowAnimationFade 动画deleteRowsAtIndexPaths:withRowAnimation: insertRowsAtIndexPaths:withRowAnimation:


This seems simple enough but as yet I am unable to find a solution.

Basically I have a segmented control with two options. The first is the default (and is automatically displayed on load) and when selected displays all rows in a table view. The second is a filter limiting the rows displayed. This is the exact same set-up as used on the "Recents" tab of the iPhone's Phone app that filters 'All' and 'Missed' calls.

At present I have the data loading from two different arrays. The problem is that when I swap the data there is no animation to denote that the rows have been filtered. Apple have implemented this in their Phone app but I can see no way of acheiving this.

Perhaps each cell will need to be deleted and re-added as the user switches between the two states - or perhaps setting the height of the cells that I wish to hide to 0 would acheive the same effect? Does anyone have any experience of producing this accordian-type animation?

I have looked here for some clues but am having problems rolling some code that works. Has anyone implemented this before? If so, how did you get it to work?

解决方案

You can accomplish a similar effect by calling deleteRowsAtIndexPaths:withRowAnimation: and insertRowsAtIndexPaths:withRowAnimation: on your table view with a UITableViewRowAnimationFade animation.

这篇关于用动画过滤UITableViewCells - iPhone开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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