我有一个有很多行的UITableView。 它就像一个手风琴:http://docs.jquery.com/UI/Accordion 主细胞有子细胞,子细胞也有子细胞。所以这是一个三级的tableView。UITableView,如何捕捉动画结束?
那么,当用户选择一个单元格时,它会用行动画扩展(或折叠)子单元格。 但我需要设置tableView和scrollView的新大小。
我做的所有的东西在这个方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
问题: 当用户点击一个单元格,然后迅速点击一个子一个,第二个动画不这样做,那么的子单元等级2未被显示。但是尺寸已经确定(考虑到二级子单元已经显示)。
其实我玩的时间来处理这个......但它真的很烂。
这里是我的代码示例:
- (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];
}
所以,我想抓住这个动画的结尾。 或者,玩一种信号量(但我只有一个过程...) 任何想法来解决这个问题?
请记住,在我的回复中,我真的是iPhone开发新手。
谢谢。
重复的:http://stackoverflow.com/questions/7198633/how-can-i-tell-when-a-uitableview-animation-has-finished。那么,也许这是一个重复的,但它有一个工作答案的好处。 – fishinear 2013-07-29 16:28:44
重复和答案是非常糟糕的。任何人都会遇到这个问题shoudl看看[UITableView动画回调](http://stackoverflow.com/questions/2802146/callback-for-uitableview-animations)和[UITableView行动画持续时间和完成回调](http:/ /stackoverflow.com/questions/3832474/uitableview-row-animation-duration-and-completion-callback) – River2202 2015-10-25 13:42:37