0

別のスクロール ビューで開く必要がある特定の画像をタップ/クリックすると、画像がコレクション ビュー グリッドに表示されるプログラムを作成しています。コレクション ビューで動的にセルを作成しています。誰もそれについて何か考えがありますか? 前もって感謝します。

4

5 に答える 5

1

タップ ジェスチャを使用する

 UITapGestureRecognizer *PressRecognizer1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handlePress:)];
            [PressRecognizer1 setNumberOfTouchesRequired:1];
             [imageview addGestureRecognizer:PressRecognizer1];

このメソッドでコードを記述します

-(void)handlePress:(UITapGestureRecognizer*)PressRecognizer {

    NSLog(@"working");

   //Add your code here for click on particular image

}
于 2013-03-13T12:24:58.513 に答える
0

didSelectItemAtIndexPathデリゲートメソッドを使用する必要があります。

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{
    // TODO: Here you need to allocate the next view and pass the image then show the view
}
于 2013-03-13T12:31:42.857 に答える
0

単純に画像を追加して使用しないのはなぜUIButtonですか?

[button setBackgroundImage:[UIImage imageNamed:@"img.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(callNewController:) forControlEvents:UIControlEventTouchUpInside];
于 2013-03-13T12:29:10.047 に答える
0

UICollectionViewDelegate の次のメソッドを実装する必要があります

- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath

ユーザーがアイテムをタップすると、メソッドが呼び出されます。

委任を設定することを忘れないでください。

于 2013-03-13T12:27:19.370 に答える
0

男はこのコードをダウンロードするだけです

http://developer.apple.com/library/ios/#samplecode/CollectionView-Simple/Listings/CollectionView_Cell_h.html

それを開始し、 DetailViewController.m に プログラムでself.imageView.image = self.image; 配置しscrollViewて追加imageViewします

于 2013-03-13T12:47:07.830 に答える