2011-02-25 4 views

답변

2

사용자가 터치하면 touchesBegan 메소드가 트리거됩니다. 첫 번째 터치가 표시된 포인터를 유지할 수 있습니다. 터치가 끝날 때까지 변경되지 않습니다.

편집 :

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    if ([touches count] == 1) 
    { 
     if (!myTouch) myTouch = [touches anyObject]; //I assume myTouch is set to nil in touchesEnded 
    } 
    else 
    { 
     //perform your logic for this case 
    } 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    if (myTouch && [touches containsObject: myTouch] 
    { 
     //perform your logic 
     myTouch = nil; 
    } 
} 

나는 당신이 터치 이벤트를 처리하는 클래스의 변수 UITouch *myTouch을 가정합니다.

+0

예를 들어 주시겠습니까? – CristiC

+0

@Parkyprg : 답변을 업데이트했습니다. – Andrew

관련 문제