动画一个UITableView时,从动画停止UITableViewCells [英] Stop UITableViewCells from animating when animating a UITableView

查看:504
本文介绍了动画一个UITableView时,从动画停止UITableViewCells的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是动画的UITableView。我想表视图​​滑开这样的:

I am animating a UITableView. I want the table view to slide open like this:

http://www.youtube.com/watch?v=XIGJLbiRsXE

然而,这样开的:

http://www.youtube.com/watch?v=UJUX-ILCB_0

注意自己是如何在表格单元格动画。我怎样才能阻止这种情况发生?

Notice how the table cells themselves are animating. How can I stop this from happening?

我使用的自动布局。在code是这样的:

I am using autolayout. The code is thus:

[theView addSubview:theTable];
[theTable reloadData];
[theTable invalidateIntrinsicContentSize];
[UIView animateWithDuration:.33 animations:^{
    [theView layoutIfNeeded];
 }];

的其它细节,其可以或可以不物质:

Other details, which may or may not matter:


  • 表视图的母公司是一个滚动视图

  • The table view's parent is a scrollView

我已经覆盖了intrinsicContentSize表格视图返回在表格视图中的所有单元格的高度,所以表视图不会滚动

I have overridden the intrinsicContentSize of the table view to return the height of all the cells in the table view, so the table view will not scroll

我改变了表视图的数据源显示前

I am changing the datasource of the table view before displaying it

推荐答案

我也有类似的问题,并能够停止对的UITableViewCell动画与UIView的 performWithoutAnimation:方法。

I had a similar problem and was able to stop the animation on the UITableViewCell with the UIView performWithoutAnimation: method.

使用的tableView:willDisplayCell:forRowAtIndexPath:的UITableViewDelegate方法获取到单元格的引用显示之前。然后, performWithoutAnimation内:块,调用 layoutIfNeeded Cell对象给它一个机会,布局其子视图上:

Use the tableView:willDisplayCell:forRowAtIndexPath: UITableViewDelegate method to get a reference to the cell before it is shown. Then, within the performWithoutAnimation: block, call layoutIfNeeded on the cell object to give it a chance to layout its subviews:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [UIView performWithoutAnimation:^{
        [cell layoutIfNeeded];
    }];
}

这篇关于动画一个UITableView时,从动画停止UITableViewCells的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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