gpt4 book ai didi

ios - "no UICollectionViewLayoutAttributes instance"是什么意思?

转载 作者:行者123 更新时间:2023-12-01 16:36:22 30 4
gpt4 key购买 nike

我的 ios 应用程序崩溃,但出现以下异常:

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

你能告诉我“-layoutAttributesForDecorationViewOfKindOfKind 没有 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

谢谢你。

最佳答案

你在实现这个方法吗?
- (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;

看起来您的单元格正在从 Collection View 中请求一些 layoutAttributes。
NSIndexPath 似乎是 [L=3, path = 3];

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

关于ios - "no UICollectionViewLayoutAttributes instance"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27870459/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com