꼬리말 보충 뷰가있는 UICollectionView가 있습니다. collectionView가 작동하는 방식으로 새 셀을 삽입 할 때 보조보기를 화면 밖으로 누를 수 있습니다. 셀의 가로 크기는 다를 수 있습니다.셀 삽입시 UICollectionView 충돌이 발생합니다.
두 개의 큰 셀을 삽입하고 보조보기를 화면에서 밀면 두 개의 큰 셀 사이에 작은 셀을 삽입하면 충돌이 발생합니다.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:
atIndexPath (UICollectionElementKindCell,<NSIndexPath: 0xc00000000000000e>
{length = 1, path = 0}) was not retrieved by calling
-dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null))'
보조보기가 nil이므로 충돌이 발생했다고 판단했습니다. 안에있는 이유는 무엇입니까?
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
나는 어떤 종류의 요소가 메서드에 전달되었는지 확인합니다. 응용 프로그램이 충돌 할 때 종류는 UICollectionElementKindCell이며 유효한 응답이 없습니다.
내 질문은 두 가지입니다.
1) 내 보완 뷰와 관련되지 않은 종류의 viewForSupplementaryElementOfKind가 호출되는 이유는 무엇입니까? UICollectionView는이 메서드에서 보완 뷰 정보를 얻으려고합니다.
2) 어떻게이 충돌을 피할 수 있습니까?
당신은 그걸로부터 어떤 뷰를 반환 할 수 있지만, 이미 당신은 footer 뷰를 사용하고 있습니다. 그래서 그것을 dequing 해보십시오. – Misha