我有UICollectionView
5个部分,一些部分有数据和一些部分(在我的代码中是第2部分)没有(它依赖于服务器)
因此,我想在选择中显示一个标签("无项目")那不是数据.
但是,我可以找到任何想法,我希望任何人都可以给我一些建议或指示来实现它.
我真的很感激任何帮助
这是我的intergrade部分代码
-(UICollectionReusableView *) collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ FriendsFanLevelHeaderView *headerView = (FriendsFanLevelHeaderView *)[self.collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"FanLevelHeader" forIndexPath:indexPath]; switch (indexPath.section) { case 0: [headerView.lblFanLevelTitle setText:@"Gold"]; break; case 1: [headerView.lblFanLevelTitle setText:@"Silver"]; break; case 2: [headerView.lblFanLevelTitle setText:@"Bronze"]; break; case 3: [headerView.lblFanLevelTitle setText:@"Green"]; break; case 4: [headerView.lblFanLevelTitle setText:@"Other"]; break; default: break; } return headerView; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ switch (section) { case 0: return 3; case 1: return 0; // it doesn't have any item case 2: return 2; case 3: return 3; case 4: return 5; default: return 0; } } - (FriendsCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ FriendsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FriendsCollectionViewCell" forIndexPath:indexPath]; [cell.lblFriendBand setText:@"Band: White Mash "]; [cell.lblFriendGenre setText:@"Freestyle house, House, Freestyle music,"]; [cell.lblFriendECScore setText:@"EC score: 79"]; return cell; }
============================================
这是我想要的