■実装
以下のようにUITapGestureRecognizerを使う。
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapped:)]; [view addGestureRecognizer:recognizer];// view.tag == VIEW_HOGE_TAG
viewがタップされると以下のメソッドが実行される。
- (void)onTapped:(UITapGestureRecognizer *)recognizer { switch (recognizer.view.tag) { case VIEW_HOGE_TAG: // hogehoge break; case VIEW_FUGA_TAG: // fugafuga break; default: break; } }