[IPhone 09.01]05. Touch

2010. 9. 1. 14:25IPhone/Basic

  아이폰이나 아이팟 터치의 가장 장점중하나가 터치가 된다는 것이다. 그터치를 얼마나 잘활용하느냐가 프로그래머가 고안해야할 방법중 하나이다.
먼저 터치를 하면 터치 메소드를 사용해야하는데 터치메소드는 UIView에 속해있는 그러므로 UIView를 상속받은 후 인터페이스빌드에서 Interaction에 UserInteraction Enabled를 체크해준다...그럼 기본적으로 터치를 사용할 준빈느 끝났다.
혹시나 듀얼터치나 그이상의 터치를 할려면 Mulitiple Touch를 클릭해주면 된다.

터치이벤트 처리 메소드
터치를 처음 했을 때        :(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;
터치를 하고 움직였을 때  :(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event;
터치를 하고있다가 땠을때:(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event;

터치 사용 예!!
 -(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
           if(1==touches.count&&1==[[touches anyObject]tapCount]){
                  //터치 할때 발생할 내용들
                  [self setNeedsDisplay]; 
           }          
}


'IPhone > Basic' 카테고리의 다른 글

[IPhone 09.01]07. 설정값 저장하기  (0) 2010.09.01
[IPhone 09.01]06. About of View  (0) 2010.09.01
[IPhone 09.01]04. TableView  (0) 2010.09.01
[IPhone 08.30]03. Objective - C의 특징  (0) 2010.08.30
[IPhone 08.30]02. 뷰 컨트롤러  (0) 2010.08.30