我正在为 UITableView 制作动画。我希望表格视图像这样滑动打开:
http://www.youtube.com/watch?v=XIGJLbiRsXE http://www.youtube.com/watch?v=XIGJLbiRsXE
然而,它打开是这样的:
http://www.youtube.com/watch?v=UJUX-ILCB_0 http://www.youtube.com/watch?v=UJUX-ILCB_0
请注意表格单元格本身的动画效果。我怎样才能阻止这种情况发生?
我正在使用自动布局。代码如下:
[theView addSubview:theTable];
[theTable reloadData];
[theTable invalidateIntrinsicContentSize];
[UIView animateWithDuration:.33 animations:^{
[theView layoutIfNeeded];
}];
其他细节,可能重要也可能不重要:
我遇到了类似的问题,并且能够使用 UIView 停止 UITableViewCell 上的动画performWithoutAnimation:
方法。
Use the tableView:willDisplayCell:forRowAtIndexPath:
UITableViewDelegate 方法在显示之前获取对单元格的引用。然后,在performWithoutAnimation:
阻止、调用layoutIfNeeded
在单元格对象上,使其有机会布局其子视图:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[UIView performWithoutAnimation:^{
[cell layoutIfNeeded];
}];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)