UICollection 뷰에 동적 CellIdentifier 이 있어야합니다.동적 셀 식별자가있는 UICollectionView
NSString *strIdentifier = [NSString stringWithFormat:@"cellIdentifier%d",indexPath.row];
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:strIdentifier forIndexPath:indexPath];
어떻게하면됩니까? 가능하다면 도와주세요 !!! 감사
이 코드
//CollectionView
self.mpCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) collectionViewLayout:layout];
[self.mpCollectionView setDataSource:self];
[self.mpCollectionView setDelegate:self];
for(int i=0;i<arrayExplorerItems.count;i++)
{
NSString* strIdentifier = [NSString stringWithFormat:@"cellIdentifier%d",i];
NSLog(@"registered Id:%@",strIdentifier);
[self.mpCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:strIdentifier];
}
and my cellForItemAtIndeaxPath is
UICollectionViewCell *cell;
NSString *strIdentifier = [NSString stringWithFormat:@"cellIdentifier%d",indexPath.row];
cell = [collectionView dequeueReusableCellWithReuseIdentifier:strIdentifier forIndexPath:indexPath];
모든 내 식별자를 등록
EDIT하지만 날이 오류를 제공
가지보기 큐에서 제거 할 수 없습니다 : UICollectionElementKindCell 식별자 cellIdentifier0과를 -해야 식별자에 펜촉이나 클래스를 등록하거나 스토리 보드에 프로토 타입 셀을 연결하십시오 '
/언제 레지스터 코드 루프를 실행합니까? – rounak
collectionview를 할당 한 직후 – Anand
cellForItem을 호출하기 전에 NSLog를 등록하려고합니까? – rounak