UITableView,如何捕捉动画结束? [英] UITableView, how to catch the end of animation?

查看:22
本文介绍了UITableView,如何捕捉动画结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含很多行的 UITableView.它就像一个手风琴:http://docs.jquery.com/UI/Accordion主细胞有子细胞,子细胞也有子细胞.所以这是一个三级tableView.

I have an UITableView with lot of rows. It is like an accordion : http://docs.jquery.com/UI/Accordion Main cells have subcells, subcells have also subcells. So this is a three-levels tableView.

好吧,当用户选择一个单元格时,它会使用行动画展开(或折叠)子单元格.但我需要设置 tableView 和 scrollView 的新大小.

Well, when the user selects a cell, it expands (or collapses) subcells with row animation. But I need to set the new size of the tableView, and the scrollView.

我用这个方法做所有的事情:

I do all that stuff in this method :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

问题:当用户点击一个单元格,然后快速点击一个子单元格时,第二个动画没有完成,因此不会显示级别 2 的子单元格.但是已经设置了大小(考虑到已经显示了级别 2 的子单元格).

The problem : When the user tap a cell, then quickly tap a sub one, the second animation isn't done, so subcells of the level 2 aren't shown. But the size has been set (taking in consideration that subcells of level 2 has been shown).

实际上我正在抓紧时间来处理这个问题......但它真的很糟糕.

Actually I'm playing with time to handle this... but it really sucks.

这是我的代码示例:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

// Checking with times (with 0,5 second interval in order to be sure that the previous animation is finished !)

// Setting tableView & scollView heights

[tableView beginUpdates];
if(position.isExpanded == YES)
    [tableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationBottom];
else 
    [tableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];
}

所以,我想抓住这个动画的结尾.或者,玩一种信号量(但我只有一个进程......)有什么想法可以解决这个问题吗?

So, I would like to catch the end of this animation. Or, playing with a kind of semaphore (but i've only 1 process ...) Any ideas to fix this ?

请记住,在您的回复中,我是 iPhone 开发方面的新手.

Please, keep in mind in your replies that I'm really new in iPhone development.

谢谢.

推荐答案

动画由 CAAnimation 类的实例控制.该类支持一个方法- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag,该方法将传递给该实例的委托.此信息通常用于获知完成情况.

The animation is controlled by a instance of class CAAnimation. This class supports a method - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag which will be delivered to the delegate of this instance. This information is typically used to get informed on the completion.

关于您的特殊要求,我会查看 UIView 类参考.有几个任务处理那个视图的动画——它是 UITableView 的基类.因此,任何对 UIView 有效的东西都应该对表格视图产生影响.

In regard to your special request i would have a look at the UIView Class reference. There are several tasks that deal with animations of that view - which is the base class of UITableView. Therefore anything that is valid for UIView should have effect on the table view.

这篇关于UITableView,如何捕捉动画结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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