문제

사용자가 탭을 튕겨 내기 위해 제스처 (왼쪽 및 오른쪽 스 와이프)를 수행 할 수있는 iPhone 앱을 만들고 있습니다. 내 문제는 일부 페이지에 Pickerview, WebView, TextFields 및 버튼과 같은 뷰가 있다는 것입니다. 스 와이프는 이것에 대해 작동하지 않습니다. 전 세계 제스처를 가질 수있는 방법이 있습니까?

참조를 위해 내 제스처 코드 예 :

//Swipe between tabs
#define mindrag 100
CGPoint mystartTouchPosition;
BOOL isProcessingListMove;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint newTouchPosition = [touch locationInView:self.view];
    if(mystartTouchPosition.x != newTouchPosition.x || mystartTouchPosition.y != newTouchPosition.y) {
        isProcessingListMove = NO;
    }
    mystartTouchPosition = [touch locationInView:self.view];
    [super touchesBegan:touches withEvent:event];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = touches.anyObject;
    CGPoint currentTouchPosition = [touch locationInView:self.view];

    // If the swipe tracks correctly.
    double diffx = mystartTouchPosition.x - currentTouchPosition.x + 0.1; // adding 0.1 to avoid division by zero
    double diffy = mystartTouchPosition.y - currentTouchPosition.y + 0.1; // adding 0.1 to avoid division by zero

    if(abs(diffx / diffy) > 2.5 && abs(diffx) > mindrag)
    {
        // It appears to be a swipe.
        if(isProcessingListMove) {
            // ignore move, we're currently processing the swipe
            return;
        }

        if (mystartTouchPosition.x < currentTouchPosition.x) {
            isProcessingListMove = YES;
            self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1];
            return;
        }
        else {
            isProcessingListMove = YES;

            self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:3];

            return;
        }
    }
    else if(abs(diffy / diffx) > 1)
    {
        isProcessingListMove = YES;
        [super touchesMoved:touches withEvent:event];
    }
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
    isProcessingListMove = NO;
    [super touchesEnded:touches withEvent:event];
}
// End of swipe

모든 입력에 감사드립니다.

도움이 되었습니까?

해결책

서브 클래스를 할 수 있습니다 UIImagePickerController 그리고 UIWebView 제스처 감지가 여전히 근본적인보기에 손질을 전달할 수있는 한이 제스처 캡처 뷰를 추가하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top