我有一个 UIImageViews userInteractionEnabled
,我想知道我当前点击的图像。我应该怎么做才能知道?我有一个海报墙和班级,ThumbPosterModel
我有我想通过的所有海报信息。
所以我的代码是:
for (ThumbPosterModel *tPoster in _thumbsPosterStack) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:tPoster.thumb];
imageView.userInteractionEnabled = YES;
imageView.frame = CGRectMake(i, imageView.frame.origin.y, imageView.frame.size.width, imageView.frame.size.height);
[_posterWallScrollView addSubview:imageView];
UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
[imageView addGestureRecognizer:tap];
}
然后我有:
-(IBAction)imageTapped:(id)sender {
//something do here, but know i don't know what.
}
我UIImageView
应该包含所有 ThumbPosterModel 参数的子类吗?我不认为这是个好主意,但我想不出任何其他解决方案。