我想在同一- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
// Configure the cell
cell.textLabel.text = [NSString stringWithFormat:@"%li", (long)indexPath.row + 1];
return cell;
}
中使用两个is_page_template('template-procedure-minimal')
。
你能帮我吗?
感谢
TRUE
答案 0 :(得分:0)
为每个单元格类型指定唯一的重用标识符,并在必要时为UICollectionViewCell
的自定义子类。在cellForItemAtPath
函数中,使用标识符来获取适合路径的标识符,例如
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.item % 2 == 0) {
EvenCollectionViewCell *cell = (EvenCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier: "evenCell" forIndexPath :indexPath];
// Configure the cell
...
return cell;
} else {
OddCollectionViewCell *cell = (OddCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier: "oddCell" forIndexPath: indexPath];
// Configure the cell
...
return cell;
}
}