IOS:UITapGestureRecognizer
UITapGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for single or multiple taps. For the gesture to be recognized, the specified number of fingers must tap the view a specified number of times.
Gesture Event on UIView
Button이 아닌 일반 UIView에 각종 터치 체스췌를 등록하는 방법이다. iOS sdk4.0부터 지원되는것으로 알고 있다.
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapPiece:)];
[piece addGestureRecognizer:tapGesture];
[tapGesture release];
tapGesture = nil;
UITapGestureRecognizer
를 만들고 액션을 지정해주면 된다. 그리고 해당 뷰에 addGestureRecognizer
를통해 등록을 해주면 해당 view에 이벤트를 등록해 줄수 있다.
- UIPanGestureRecognizer
- UILongPressGestureRecognizer
위처럼 Tab이외에도 여러 이벤트가 있고 잘 활용하면 편하게 이벤트를 관리 할수 있을것이다
Gesture Event on UIImageVIew
만약 UIImageView에도 적용하고 싶을 경우 아래의 속성을 추가해야 한다.