내 코드가 cellForItemAtIndexPath:
&이 아닌 dequeueReusableCellWithReuseIdentifier:
으로 잘 작동하는지 궁금해하고 있습니다. 컬렉션 뷰 셀을 가져 오는 중입니다. 이 잘 컴파일하지만 (I 셀에서 수행하는 변경 사항이 묘사되지 않음)dequeueReusableCellWithReuseIdentifier와 cellForItemAtIndexPath의 차이점 :
NSInteger numberOfCells = [self.collectionView numberOfItemsInSection:0];
for (NSInteger i = 0; i < numberOfCells; i++) {
myCustomCollectionCell *cell = (myCustomCollectionCell *)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
//here I use the cell..
}
:
이이 하나가 잘 작동 : 여기
내 코드입니다NSInteger numberOfCells = [self.collectionView numberOfItemsInSection:0];
for (NSInteger i = 0; i < numberOfCells; i++) {
myCustomCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"myCell"forIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
//here I use the cell..
}
시도해 보았습니다. 그러나 아무 사용 :
NSInteger numberOfCells = [self.collectionView numberOfItemsInSection:0];
for (NSInteger i = 0; i < numberOfCells; i++) {
myCustomCollectionCell *cell = (myCustomCollectionCell *)[self.collectionView dequeueReusableCellWithReuseIdentifier:@"myCell"forIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
//here I use the cell..
}
어떤 아이디어?
dequeueReusableCellWithReuseIdentifier를 사용하기위한 전제 조건은 registerClass : forCellReuseIdentifier를 사용하는 것입니다. - 수행 했습니까? 동일한 재사용 식별자를 사용하고 있습니까? –
셀 클래스를 등록하지 않고 'dequeueReusableCellWithReuseIdentifier'의 indexPath가 아닌 버전을 사용할 수 있습니다. 무제한으로 구현하려면 기본 iOS 샘플 코드를 살펴 봐야합니다. – Neil
@neil .. 너를 얻지 못 했어 .. –