사용자가 화면에서 손가락을 떼지 않고 UIButton 내부의 터치를 감지하는 방법이 있습니까?화면에서 손가락을 떼지 않고 터치 버튼을 누르십시오.
예 : 두 개의 버튼이 있고 사용자가 왼쪽 버튼을 탭한 다음 손가락을 오른쪽으로 드래그하면 애플리케이션에서 오른쪽 버튼을 탭하고 있음을 인식해야합니다.
사용자가 화면에서 손가락을 떼지 않고 UIButton 내부의 터치를 감지하는 방법이 있습니까?화면에서 손가락을 떼지 않고 터치 버튼을 누르십시오.
예 : 두 개의 버튼이 있고 사용자가 왼쪽 버튼을 탭한 다음 손가락을 오른쪽으로 드래그하면 애플리케이션에서 오른쪽 버튼을 탭하고 있음을 인식해야합니다.
UIViewController를 사용하여 직접 구현하고 싶습니다.
대신 버튼을 사용하십시오.
두 개의보기를 화면에 표시합니다 (각 버튼마다 하나씩).이 단추, imageView 또는 UIView 만 만들 수 있지만 userInteractionEnabled = NO;
인지 확인하십시오.
그런 다음 UIViewController에서 touchesBegan
및 touchesMoved
메서드를 사용하십시오.
... 그런 다음 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;
}
}
어쨌든 이런 것이 있습니다.
기존 버튼 이벤트를 사용하여이 작업을 수행 할 수 있어야합니다. 예 : '외부로 터치 드래그', '외부로 터치', '터치 드래그 종료'등
이러한 이벤트를 등록하고 필요에 맞는 것을 확인하십시오.
예, 이것은 내 것보다 낫지 만 근본적으로 똑같습니다. 터치 드래그 안쪽과 터치 드래그 바깥쪽에 대해서는 몰랐습니다 ... – Fogmeister