2015-01-09 126 views
1

我的iOS應用程序崩潰,並顯示以下異常:「no UICollectionViewLayoutAttributes實例」是什麼意思?

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

能否請你告訴我什麼是「不UICollectionViewLayoutAttributes實例-layoutAttributesForDecorationViewOfKindOfKind」的含義?我應該在哪裏尋找麻煩拍攝它?

我已經implmenemtned這個方法:

- (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 

謝謝。

回答

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中進一步調查。

+0

謝謝。我已經暗示了你所建議的方法。但是當我將模擬器從Protait旋轉到風景時,我遇到了新的崩潰。我已經更新了我的問題。 – michael 2015-01-10 01:42:39