Я хочу, чтобы UICollection отображал динамический CellIdentifier , похожий на follwoing.UICollectionView с динамическим идентификатором ячейки
NSString *strIdentifier = [NSString stringWithFormat:@"cellIdentifier%d",indexPath.row];
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:strIdentifier forIndexPath:indexPath];
Как это сделать? Если это возможно, пожалуйста, помогите !!! Благодаря
EDIT
Я зарегистрировал все мои идентификаторы с этим кодом
//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];
но дает мне эту ошибку
не мог из очереди вида рода: UICollectionElementKindCell с идентификатором cellIdentifier0 - должно зарегистрировать нить или класс для идентификатора или подключить прототип ячейки в раскадровке '
Где/когда вы выполняете цикл кода регистров? – rounak
Вскоре после выделения collectionview – Anand
Я получаю NSLog для регистрации до вызова cellForItem? – rounak