我想创建4个不同类型的多个collectionViewCells。每个细胞对这四种类型之一有不同的看法。基于用户选择,这些类型的每个视图都可以具有不同的内容。collectionView单元格重叠
我遇到的问题是,当屏幕上显示相同类型的多个视图/单元格时,某些卡片重叠/无法正确加载。
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
Card *card = [[[usermanager getSelectedUser] getCards] objectAtIndex:indexPath.item];
NSLog(@"CARD LOADING: %@", card.title);
[card setupLayout];
UICollectionViewCell *cell;
if(card.type.intValue == 1){
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"lifestyleCell" forIndexPath:indexPath];
}else if(card.type.intValue == 2){
cell= [collectionView dequeueReusableCellWithReuseIdentifier:@"sceneCell" forIndexPath:indexPath];
}else if(card.type.intValue == 3){
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"energyCell" forIndexPath:indexPath];
}else if(card.type.intValue == 4){
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"productCell" forIndexPath:indexPath];
}else{
cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cardCell" forIndexPath:indexPath];
}
[cell addSubview:card];
//Add dropshadow
cell.contentView.layer.borderWidth = 1.0f;
cell.contentView.layer.borderColor = [UIColor clearColor].CGColor;
cell.contentView.layer.masksToBounds = YES;
cell.layer.shadowColor = [UIColor blackColor].CGColor;
cell.layer.shadowOffset = CGSizeMake(0, 5.0f);
cell.layer.shadowRadius = 2.0f;
cell.layer.shadowOpacity = 0.5f;
cell.layer.masksToBounds = NO;
return cell;
}
卡是我添加到单元格中的视图。如上所述,这些卡有多种类型。
谢谢你,我会看看这个方法用于固定号码我有其他问题;) –