2010-11-21 8 views
18

UIScrollView를 사용하고 있으며 scrollRectToVisible을 사용하고 있습니다. animated 이것은 나를 위해 잘 작동합니다. 하지만 사용자가 효과를 느낄 수 있도록 위치를 천천히 스크롤하고 싶습니다. 가능합니까?iphone - 느린 애니메이션이있는 UIScrollview - scrollRectToVisible

다음 코드를 시도했지만 성공하지 못했습니다.

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDuration:2.0]; 
[scrlView scrollRectToVisible:<<some cgrect>> animated:YES];    
[UIView commitAnimations];   
+0

중복 가능성 (http://stackoverflow.com/questions/1558262/uiscrollview-scrollrecttovisible-at-custom-speed) – tbodt

답변

55

실제로 솔루션은 실제로 매우 쉽습니다. [scrollView scrollRectToVisible:frame animated:YES]을 사용하는 경우 scrollview에서 자체 애니메이션을 시작하므로 애니메이션 기간에 애니메이션을 사용하려면 애니메이션 내에 [scrollView scrollRectToVisible:frame animated:NO]을 사용해야합니다.

즉 : 이것은 작동합니다.

[UIView animateWithDuration:3 
         delay:0 
        options:UIViewAnimationOptionCurveEaseInOut 
       animations:^{ [scrollView scrollRectToVisible:frame animated:NO]; } 
       completion:NULL]; 
[지정 속도로 scrollRectToVisible있는 UIScrollView]의
관련 문제