在containerview

时间:2015-07-29 09:24:39

标签: ios objective-c iphone ios7 storyboard

我在故事板中有一个控制器,它包含两个容器视图。我将两个容器之间的垂直距离设置为零。

我想要的是在运行时更改其中一个容器的高度约束。

以下是更改约束的代码:

[UIView animateWithDuration:kAnimationDuration animations:^{
    self.offeringContainerHeightConstraint.constant = [SJDataManager shared].offeringItems.count * kOfferingCellHeight + kOfferingHeaderHeight;
    [self.view layoutIfNeeded];
}];

问题是,另一个容器视图在此之前移动,因此在动画完成之前两个容器之间存在空白区域。

我希望两个容器视图在同步时更改其约束值,以便可以删除此闪烁。

1 个答案:

答案 0 :(得分:0)

我终于找到了解决方案。实际上它是expectedHeightForRowAtIndexPath和heightForRowAtIndexPath之间的区别。由于这两种方法返回的高度不同,这就是我得到闪烁的原因。