2010-03-10 4 views
1

그래서 기본적으로 UIScrollView를 더 높은 각도로 스크롤하려고합니다. 현재와 ​​마찬가지로 손가락을 수평에서 10도 이동하면 스크롤보기가 스크롤됩니다. 30도 정도까지 밀어 내고 싶습니다.프로그래밍 방식으로 스크롤하여 UIScrollView로 스크롤하여

몇 가지 독서를 한 후에 스크롤바 상단에 하위 클래스 UIView를 배치하는 것이 가장 좋은 방법입니다. 상단 터치의 UIView가 30도 이상인 경우 scrollview로 전달하고 그렇지 않으면 스크롤하지 않습니다.

그러나 터치를 전달하는 방법을 알 수 없습니다. 지금 내 코드는 다음과 같습니다.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSLog(@"glass touch began"); 
    UITouch *touch = [touches anyObject]; 
    beginning_touch_point = [touch locationInView:nil]; 
    [scroll_view touchesBegan:touches withEvent:event]; 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSLog(@"glass touch ended"); 
    UITouch *touch = [touches anyObject]; 
    CGPoint previous_point = beginning_touch_point; 
    CGPoint current_point = [touch locationInView:nil]; 

    float x_change = fabs(previous_point.x - current_point.x); 
    float y_change = fabs(previous_point.y - current_point.y); 

    if(x_change > y_change) 
    { 
     if(previous_point.x - current_point.x < 0) 
     { 
      [(MyScheduleViewController *)schedule_controller didFlickLeft]; 
     } 
     else 
     { 
      [(MyScheduleViewController *)schedule_controller didFlickRight]; 
     } 

     [scroll_view touchesCancelled:touches withEvent:event]; 
    } 
    else 
    { 
     [scroll_view touchesEnded:touches withEvent:event]; 
    } 
} 

저는 45도를 확인하고 있지만 지금은 중요하지 않습니다. 중요한 점은 터치가 실제로 내 scroll_view로 올바르게 전달된다는 것입니다. 나는 그것이 touchesbegan과 touchesended에 대해 NSLog()를 수행하고 있으며, 올바르게 수행하고있다. 스크롤 만하는 것이 아닙니다. 나는 건드린다고 걱정한다 .Began and touchesEnded는 스크롤을 일으킬 수 없다. 아무도 뭘 할 수 있는지, 내가 뭘 잘못하고 있는지 아는가 ??

감사합니다.

+1

이 기능을 작동 시키셨습니까? 현재 비슷한 문제가 있습니다. –

답변

0

나는 똑같이하려고했지만 성공하지 못했습니다. scrollView는 touchesMoved/touchesBegan을 처리하지 않지만 사용자가보기를 스크롤하려고한다는 것을 이해하기 위해 다른 이벤트를 처리합니다. 나를 위해 해결책은 thet 시프트 값을 결정하고 명시 적으로 scrollView 내용 오프셋으로 설정하는 것이 었습니다. (정확한 소스 코드가 없으므로이 코드가 올바르게 작동하지 않을 수 있습니다.)

관련 문제