2013-07-17 3 views
0

그래서이 uiscrollerview가 있습니다 ... 매 5 초가 지나면 scrollview가 위로 이동해야합니다.보기에서 스크롤 애니메이션을 만드는 방법

setcontentoffset이 작동하지만 애니메이션이 없습니다. 천천히 움직여야하는 것처럼. 사전

+0

어떻게 ScrollView 코드를 여기에 스크롤 할 수 있습니까? – iPatel

+0

[scrollView setContentOffset : offset animated : YES]; –

답변

0
[UIView animationWithDuration0.3f ^(void) { 

// code to do the transition 

}]; 

UIView Reference

[scrollView setContentOffset:offset animated:YES]; 

UIScrollView Reference

+0

작동하지 않습니다 ... [UIView animationWithDuration : 0.3f^(void) { [scroll setContentOffset : bottomOffset 애니메이션 : 예]; }]]; – antonoVodka

+0

두 가지 옵션이 있습니다 .... 하나 또는 다른 것을 할 수 있습니다 [UIView animationWithDuration0.3f^(void) { [scroll setContentOffSet : offSet]; }]]; 또는 [scrollView setContentOffset : offset animated : YES]; –

+0

'[UIView animateWithDuration : 1.00f 지연 : 0.0f 옵션 : UIViewAnimationOptionCurveEaseOut 애니메이션 :^{ [scroll setContentOffset : bottomOffset]; } 완료 :^(BOOL 완료) { }]; ' – antonoVodka

3

에서

CGPoint bottomOffset = CGPointMake(0, newYLocationForScrollView); 

[scroll setContentOffset:bottomOffset animated:YES];

덕분에 아래

내 코드는 당신이 찾고있는 방법은 scrollRectToVisible:animated:입니다. 자세한 내용이 없으면 원하는 직각을 계산할 코드를 남겨 두어야합니다.

1

사용있는 ScrollView scrollRectToVisible:animated: 방법 및 제공 animated 재산 YES

또는

[UIView animateWithDuration:1.2f animations:^{ 
     /// write code for animation 
    }]; 
+0

작동하지 않습니다 ... [UIView animationWithDuration : 0.3f^(void) { [scroll setContentOffset : bottomOffset animated : YES]; }]]; – antonoVodka

+0

[scroll setContentOffset : bottomOffset animated : YES]; 이 메서드를 애니메이션 "YES"로 사용하면 다른 애니메이션을 사용할 필요가 없습니다.이 메서드는 자체 애니메이션을가집니다. – iPatel

관련 문제