Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用containerview上需要的布局时闪烁_Ios_Objective C_Iphone_Ios7_Storyboard - Fatal编程技术网

Ios 使用containerview上需要的布局时闪烁

Ios 使用containerview上需要的布局时闪烁,ios,objective-c,iphone,ios7,storyboard,Ios,Objective C,Iphone,Ios7,Storyboard,我在故事板中有一个控制器,它由两个容器视图组成。我将两个容器之间的垂直距离设置为零 我想要的是在运行时更改其中一个容器的高度约束 以下是更改约束的代码: [UIView animateWithDuration:kAnimationDuration animations:^{ self.offeringContainerHeightConstraint.constant = [SJDataManager shared].offeringItems.count * kOfferingCell

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

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

以下是更改约束的代码:

[UIView animateWithDuration:kAnimationDuration animations:^{
    self.offeringContainerHeightConstraint.constant = [SJDataManager shared].offeringItems.count * kOfferingCellHeight + kOfferingHeaderHeight;
    [self.view layoutIfNeeded];
}];
问题是,另一个容器视图在前面移动,因此在动画完成之前,两个容器之间存在空白区域


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

我终于找到了解决方案。实际上,这是Rowatindexpath的预期高度与Rowatindexpath的预期高度之间的差异。由于这两种方法返回的高度不同,因此我得到了闪烁

我终于找到了解决办法。实际上,这是Rowatindexpath的预期高度与Rowatindexpath的预期高度之间的差异。由于这两种方法返回的高度不同,因此我得到了闪烁

我认为(但我不确定)animateWithDuration在后台线程上执行,而layoutIfNeeded应该在主线程上执行。如果将其封装为dispatch_async(dispatch_get_main_queue(),^{[self.view layoutifneed];}),会发生什么;这使得整个动画一次发生,看起来很糟糕。我想这是你的意图对不起。但是闪烁至少消失了吗?是的,闪烁消失了,但我想要的是没有闪烁的动画。我认为(但我不确定)animateWithDuration在后台线程上执行,而layoutIfNeeded应该在主线程上执行。如果将其封装为dispatch_async(dispatch_get_main_queue(),^{[self.view layoutifneed];}),会发生什么;这使得整个动画一次发生,看起来很糟糕。我想这是你的意图对不起。但是闪烁至少消失了吗?是的闪烁消失了,但是我想要的是没有闪烁的动画。