「ios開発」UIImageViewを利用してイベントクリック動作を追加する方法
コード下記:
UIImageView *imageView = [self getYourImageView];
imageView.image = [self getYourImage];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourHandlingCode:)];
[imageView addGestureRecognizer:singleTap];
//イベントを取得
-(void)yourHandlingCode:(UIGestureRecognizer *)gestureRecognizer
{
UIImageView *view = [gestureRecognizer view];
int tagvalue = view.tag;
}