Привет, у меня есть UICollectionView
. Я загружаю данные из NSMutableArray
и имеет 4 объекта. Но моя проблема заключается в повторении того же самого ячеек.Как избежать повторяющихся ячеек UICollectionView?
`
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return mutArrayArtists.count;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {
return 2;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
artist = [mutArrayArtists objectAtIndex:indexPath.row];
UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
recipeImageView.image = artist.artistImage;
UILabel *lblArtistname=(UILabel *)[cell viewWithTag:102];
lblArtistname.text=artist.artistName;
UILabel *lblSongCount=(UILabel *)[cell viewWithTag:101];
lblSongCount.text=artist.numberofSongs;
return cell;
}
`
Но результат, как этот
Как я могу избежать этого? Пожалуйста, помогите мне
Благодаря
Он показывает количество как 4 – user2889249
вы объявленную иметь две секции в вашем CollectionView, но в '' numberOfItemsInSection'and cellForItemAtIndexPath' вы не принимая во внимание раздел – tkanzakic