如何区分单个UICollectionViewCell处理

时间:2016-10-17 03:30:20

标签: ios cocoa-touch

如何区分单个UICollectionViewCell处理。我根据indexPath行处理它将是一个问题。

1 个答案:

答案 0 :(得分:0)

UICollection视图有一个类似于tableView的委托方法

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
    cell.layer.borderWidth = 1;
    cell.layer.borderColor = [[UIColor whiteColor]CGColor];
    UIImageView *image = [[UIImageView alloc]init];
    image.image = [UIImage imageWithData:[self.imagesGallery objectAtIndex:indexPath.row]];
    image.frame = CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height);
    [cell addSubview:image];
    return cell;
}