UIImageViewでタッチイベントをとりたかったので、tagをつけることにしました。
ただタグをつけるだけでは、UIImageViewのタッチイベントが取れません。
「User Interaction Enabled」にチェックを入れる必要があります。
これでタッチイベントが取れるようになります。
- (void) touchesEnded:(NSSet *) touches withEvent: (UIEvent *) event { UITouch * touch = [[event allTouches] anyObject]; if (touch.view.tag ==self.imageView.tag) { NSLog(@"Tap."); } }
ソースで書くと以下のようになります。
self.imageView.userInteractionEnabled =
YES
;
self.
imageLogo.tag = 100;
参考サイト: