2012-11-12 5 views

답변

0

UIViewController를 사용하여 직접 구현하고 싶습니다.

대신 버튼을 사용하십시오.

두 개의보기를 화면에 표시합니다 (각 버튼마다 하나씩).이 단추, imageView 또는 UIView 만 만들 수 있지만 userInteractionEnabled = NO;인지 확인하십시오.

그런 다음 UIViewController에서 touchesBegantouchesMoved 메서드를 사용하십시오.

내가 같은의 ViewController에서 몇 가지 상태를 절약 할 수

... 그런 다음 touchesBegan이보기 중 하나 내부에있는 경우

BOOL trackTouch; 
UIView *currentView; 

...있는 touchesMoved 그런
-(void)touchesBegan... (can't remember the full name) 
{ 
    UITouch *touch = [touches anyObject]; 
    CGPoint point = [touch locationInView:self.view]; 
    if (CGRectContainsPoint(firstView, point)) { 
     trackTouch = YES 
     //deal with the initial touch... 
     currentView = firstView; (work out which view you are in and store it) 
    } else if (CGRectContainsPoint(secondView, point)) { 
     trackTouch = YES 
     //deal with the initial touch... 
     currentView = secondView; (work out which view you are in and store it) 
    } 
} 

...

- (void)touchesMoved... (can't remember the full name) 
{ 
    UITouch *touch = [touches anyObject]; 
    CGPoint point = [touch locationInView:self.view]; 
    if (CGRectContainsPoint(secondView, point) and currentView != secondView)) { 
     // deal with the touch swapping into a new view. 
     currentView = secondView; 
    } else if (CGRectContainsPoint(firstView, point) and currentView != firstView)) { 
     // deal with the touch swapping into a new view. 
     currentView = firstView; 
    } 
} 

어쨌든 이런 것이 있습니다.

2

기존 버튼 이벤트를 사용하여이 작업을 수행 할 수 있어야합니다. 예 : '외부로 터치 드래그', '외부로 터치', '터치 드래그 종료'등

이러한 이벤트를 등록하고 필요에 맞는 것을 확인하십시오.

+0

예, 이것은 내 것보다 낫지 만 근본적으로 똑같습니다. 터치 드래그 안쪽과 터치 드래그 바깥쪽에 대해서는 몰랐습니다 ... – Fogmeister

관련 문제