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이외에도 여러 이벤트가 있고 잘 활용하면 편하게 이벤트를 관리 할수 있을것이다
반응형
'2013 이전 > iOS개발' 카테고리의 다른 글
[iPhone 개발] keyboard 애니메이션 정보 얻기 (0) | 2017.02.25 |
---|---|
[iPhone 개발] mov 파일 mp4로 변환하기 (0) | 2017.02.25 |
[iPhone 개발] CGImage의 Orientation (0) | 2017.02.25 |
[iPhone 개발] 이미지 일부 늘리기 (0) | 2017.02.25 |
[iPhone 개발] 키보드 변경에 따른 View 변환 (0) | 2017.02.25 |