我在重置此方法
中的集合视图框架(summaryView)时收到此错误- (void)configureSubviews{
_close.frame = CGRectMake(rect.origin.x, 10 , 51, 35);
[_close setBackgroundImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateNormal];
[_close setBackgroundImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateSelected];
[_close setBackgroundImage:[UIImage imageNamed:@"close.png"] forState:UIControlStateHighlighted];
[_close addTarget:self action:@selector(closeDetailView:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_close];
_dragger.frame = CGRectMake((rect.size.width-35)/2, 28, 23, 10);
_dragger.image = [UIImage imageNamed:@"summary_dragger_portrait.png"];
_draggerView.frame = CGRectMake(0, 0, rect.size.width, 40);
_contentView.frame = CGRectMake(0, 13, rect.size.width, rect.size.height);
[_summaryView.collectionViewLayout invalidateLayout];
_summaryView.frame = CGRectMake(0, 50, rect.size.width, rect.size.height-93);// exception occurs on this line
_borderView.frame = CGRectMake(0, 36, rect.size.width, 0.5);
actionX = rect.size.width-41;
}
例外:
MyApp [2585:728612] *断言失败 - [UICollectionViewData validateLayoutInRect:] /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.12/UICollectionViewData.m:408 2016-08-11 11:22:05.175 MyApp [2585:728612] * 终止应用程序 未捕获的异常'NSInternalInconsistencyException',原因:'布局 索引路径({length = 2,path = 0 - 0})上的补充项的属性已从 索引路径: ({length = 2,path = 0 - 0});元素种类: (SummarySuppView); frame =(6 0; 743 65); zIndex = -1;至 索引路径: ({length = 2,path = 0 - 0});元素种类: (SummarySuppView); frame =(6 0; 743 65); zIndex = -1;无 使布局无效
此方法从动画块
调用UIView transitionWithView:self.view duration:0.15
options: (UIViewAnimationOptions)UIViewAnimationTransitionCurlUp
animations:^ {
[self layoutDataViewsForSize:listSize];
[self layoutSummaryViewsForSize:summarySize];
[_summaryView layoutSubviews]; // method call
}
completion:^(BOOL finished){
if (_filterActions.alpha==0) {
_filterActions.alpha= 1.0f;
}
}];
答案 0 :(得分:0)
这是因为您更改了布局而没有在其中的所有视图中调用invalidate。尝试在layoutSubviews中调用super,这可能有帮助
-(void)layoutSubviews {
[super layoutSubviews];
...your code
}
答案 1 :(得分:0)
添加此
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
[viewCollection.collectionViewLayout invalidateLayout];
}