私はサブビューとして追加された画像を持つscrollviewを持っています。私は画像を選択したりタップしたりできる必要があります。つまり、タップされた画像の名前を取得します。以下の私のコードを見てください。UIScrollviewで特定の画像を選択
for (j = 1; j <= 12; j++)
{
NSString *imageName = [NSString stringWithFormat:@"%@",[months objectAtIndex:j-1]];
NSLog(@"imagename is %@",imageName);
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
CGRect rect = imageView.frame;
rect.size.height = smallScrollObjHeight;
rect.size.width = smallScrollObjWidth;
imageView.frame = rect;
imageView.tag = j;
[smalltapRecognizer setNumberOfTapsRequired:1];
[smalltapRecognizer setDelegate:self];
[imageView addGestureRecognizer:smalltapRecognizer];
[smalltapRecognizer release];*/
NSLog(@"tag value is %d ",imageView.tag);
[monthscroll addSubview:imageView];
[imageView release];
}
[self layoutsmallScrollImages];
UITapGestureRecognizer *smalltapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(smalltapped:)];
[smalltapRecognizer setNumberOfTapsRequired:1];
[smalltapRecognizer setDelegate:self];
[monthscroll addGestureRecognizer:smalltapRecognizer];
[smalltapRecognizer release];
// ----------------------------
- (無効)smalltapped:(id)を送信者 { NSLog(@ "タップ"); //ここから進める方法を知る必要があります。 }
私のプログラムはタップを検出し、タップログを小タップ機能に出力します。私はどのように選択またはタップ画像の名前をキャプチャすることができます知る必要があります。
音が良いアイデアのように、明日それを試してみましょう – Rajashekar