[ios] Handling UIKit Gestures
Handling UIKit Gestures Gesture recognizer를 사용하는 것은 뷰에서 발생하는 Touch나 Press 이벤트를 다룰수 있는 가장 간단한 방법입니다. 어떤 뷰든간에 한 개 혹은 복수 개의 Gesture에 대한 recognizer를..
baked-corn.tistory.com
iOS ) ScrollView에서 위아래 Gesture를 감지하고싶다면? / UIGestureRecognizerDelegate
iOS ) ScrollView에서 위아래 Gesture를 감지하고싶다면? / UIGestureRecognizerDelegate
안녕하세요 :) Zedd입니다. 알아두면 좋은 사실을 발견해서 글 씁니댜 제 이전글인 Pan Gesture를 보셨나요? 상하좌우로 드래깅하는 Gesture를 감지할 수 있었는데요, 제가 예제로 사용한건 그냥 View에서의 image..
zeddios.tistory.com
Allowing the Simultaneous Recognition of Multiple Gestures | Apple Developer Documentation
Article Allowing the Simultaneous Recognition of Multiple Gestures Learn how to use a delegate object to allow detection of more than one gesture at a time. OverviewThere are times when it makes sense to allow the simultaneous recognition of multiple gestu
developer.apple.com
shouldRecognizeSimultaneouslyWith
- return true
- 두 제스처를 동시에 인식하도록 허용한다.
- 제스처 인식기가 롱프레스 라면 동시 인식을 허용하지 않는 코드
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer)
-> Bool {
// If either gesture recognizer is a long press, do not allow
// simultaneous recognition.
if gestureRecognizer is UILongPressGestureRecognizer ||
otherGestureRecognizer is UILongPressGestureRecognizer {
return false
}
return true
}
- return false
- 기본값
- 두 제스처를 동시에 인식할 수 없습니다.
shouldRequireFailureOf
- gesture Recognizer가 다른 gesture Recognizer를 실패 경우, 위임자에게 요청합니다.
shouldBeRequiredToFailBy
- gesture Recognizer가 다른 gesture Recognizer에 의해 실패해야하는 경우 위임자에게 요청합니다.
cancelsTouchesInView
- true
- 기본값
- Gesture Recognizer가 gesture를 인식하면 나머지 터치 정보들을 뷰로 전달하지 않고 이전에 전달된 터치들은 취소됩니다. (touchesCancelled)
- ex) doubleTapGestureRecognizer
- touchesBegan → gesture action → touchesCancelled
- false
- gesture를 인식한 후에도 터치 정보를 뷰에 전달하게 됩니다.
- ex) doubleTapGestureRecognizer
- touchesBegan → gesture action → touchesEnded
delaysTouchesBegan
- true
- recognizer가 패턴을 검사하는 동안에는 터치의 최초 발생 이벤트를 뷰로 전달하지 않고 보류합니다.
- ex) doubleTapGestureRecognizer
- gesture action → X
- false
- 기본값
- ex) doubleTapGestureRecognizer
- touchesBegan → gesture action → touchesCancelled
댓글