1

UICollectionView画像ギャラリーを生成するために使用しています。画像をロードするために内部で使用しましたUIImage。(シングルタップではなく)長押しUICollectionView Cellで選択する必要があります。UICollectionView Cell

4

1 に答える 1

2

didSelectItemAtIndexPathデリゲート コールバックを取得し、セルを取得して、画像をサブビューとして追加するだけです。

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    YourCollectionViewCell *cell = (YourCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
    UIImageView *yourImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];//whichever frame you want it to appear at
    yourImageView.image = [UIImage imageNamed:@"yourImageName"];//set the image
    [cell.yourBaseImage addSubview:yourImageView];//or add it to whatever part of the cell you want
}

または、Storyboard 内にすでに非表示の imageView を設定しておくこともできます。そして、それを再表示して、画像を中に設定しますdidSelectItemAtIndexPath

于 2013-08-13T17:04:04.840 に答える