animationUITableView时停止从animationUITableViewCells
我正在animationUITableView。 我希望桌面视图像这样滑动打开:
但是,它是这样打开的:
注意表格单元格本身是如何animation的。 我怎样才能阻止这种情况发生?
我正在使用自动布局。 代码是这样的:
[theView addSubview:theTable]; [theTable reloadData]; [theTable invalidateIntrinsicContentSize]; [UIView animateWithDuration:.33 animations:^{ [theView layoutIfNeeded]; }];
其他细节,这可能或可能不重要:
-
表视图的父项是一个scrollView
-
我已经重写了表视图的intrinsicContentSize以返回表视图中所有单元格的高度,所以表视图将不会滚动
-
在显示之前,我正在更改表视图的数据源
我有一个类似的问题,并能够停止与UIView performWithoutAnimation:
方法的UITableViewCell上的animation。
使用tableView:willDisplayCell:forRowAtIndexPath:
UITableViewDelegate方法在显示之前获取单元格的引用。 然后,在performWithoutAnimation:
块内,调用cell对象上的layoutIfNeeded
,给它一个布局它的子视图的机会:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { [UIView performWithoutAnimation:^{ [cell layoutIfNeeded]; }]; }
回答这个问题可能为时已晚,但这种情况下的问题通常在于animation块捕获下一个运行循环中计划的所有未决布局。
我使用的解决scheme是。 我在animation之前调用layoutIfNeeded(在设置或使任何约束无效之前),然后在animation块内。
在你的情况下,这将是这样的事情,
[theView addSubview:theTable]; [theTable reloadData]; [theView layoutIfNeeded]; [theTable invalidateIntrinsicContentSize]; [UIView animateWithDuration:.33 animations:^{ [theView layoutIfNeeded]; }];
你有没有考虑animation而不是一个不透明的子视图,位于表视图之上?
[theView addSubview:theTable]; [theTable reloadData]; UIView *subview = [[UIView alloc] initWithFrame:theTable.frame]; subview.backgroundColor = [UIColor whiteColor]; [theView addSubview:subview]; [UIView animateWithDuration:0.33 animations:^{ subview.frame = CGRectMake(subview.frame.origin.x, subview.frame.size.height, subview.frame.size.width, 0.0); }];
在调用animation块内的[layout layoutIfNeeded]之前,先尝试布置表格。 理想情况下,你可以零散布局,为了0.33秒,你可能会在桌面上看到一个滚动条,但目标是让animation块之外的表格单元布局变化。
- 以编程方式添加与Autolay的UISLider
- 宽度和高度等于它的超级查看使用自动布局编程?
- 当Autolay正在播放时,用UIDynamicAnimator进行animation处理
- UILabel显示在debugging视图层次结构中,但不在应用程序中
- 从Storyboard加载自定义的UITableViewCell
- iOS 7 UITableViewCell与AutoLayout的冲突约束
- 在iOS上,边距,边缘插入,内容插入,alignmentmatrix,布局边距,锚点之间有什么区别?
- 如何通过故事板自动布局来适应tableview到导航栏下的superview
- iOS >>拖动视图跳回原始位置>>自动布局与UIPanGestureRecognizer问题结合