"没有UICollectionViewLayoutAttributes实例"是什么意思?

时间:2015-01-09 22:42:29

标签: ios

我的ios应用程序因以下异常而崩溃:

void HandleExceptions(NSException *__strong):875 ERROR: uncaught exception: no UICollectionViewLayoutAttributes instance for -layoutAttributesForDecorationViewOfKindOfKind: ColorDecoratorView at path <NSIndexPath: 0x7d843ec0> {length = 3, path = 3 - 0}

请告诉我“-outoutAttributesForDecorationViewOfKindOfKind没有UICollectionViewLayoutAttributes实例”是什么意思?我应该在哪里找麻烦拍摄它?

我已经明白了这种方法:

   - (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind atIndexPath:(NSIndexPath *)indexPath

但是当我旋转屏幕时,我得到以下异常:

uncaught exception: layout attributes for supplementary item at index path (<NSIndexPath: 0x79ef2c80> {length = 2, path = 1 - 0}) changed from <UICollectionViewLayoutAttributes: 0x82e76830> index path: (<NSIndexPath: 0x79ebf750> {length = 2, path = 1 - 0}); element kind: (ColorDecoratorView); frame = (72 2513; 293.333 252);  to <UICollectionViewLayoutAttributes: 0x79ef9380> index path: (<NSIndexPath: 0x79ef2c80> {length = 2, path = 1 - 0}); element kind: (ColorDecoratorView); frame = (0 825; 1024 -327);  without invalidating the layout

谢谢。

1 个答案:

答案 0 :(得分:0)

你正在实施这个方法吗?

- (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind atIndexPath:(NSIndexPath *)indexPath

返回值为 A layout attributes object containing the information to apply to the decoration view.

我想说实现这个方法。这样的事情  UICollectionViewLayoutAttributes *attrs = [UICollectionViewLayoutAttributes layoutAttributesForDecorationViewOfKind:decorationViewKind withIndexPath:indexPath]; attrs.frame = cgrectmake (x,x,x,x); return attrs;

看起来你的单元格正在从集合视图中请求一些layoutAttributes。 NSIndexPath似乎是[L = 3,path = 3];

获取indexPath.row并进一步调查cellForRowAtIndexPath。