动画一个UITableView时,从动画停止UITableViewCells [英] Stop UITableViewCells from animating when animating a UITableView
问题描述
我是动画的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屋!