2013-07-17 2 views
0

Итак, у меня есть этот uiscrollerview ... каждый раз, когда проходит 5 секунд, scrollview должен двигаться вверх.Как сделать анимацию прокрутки на вид

setcontentoffset работает, но у него нет анимации. как будто он должен двигаться медленно.

мой код ниже

CGPoint bottomOffset = CGPointMake(0, newYLocationForScrollView); 

[scroll setContentOffset:bottomOffset animated:YES];

спасибо заранее

+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

Это были 2 отдельных варианта .... вы можете сделать один или другой [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

метод вы ищете 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]; если вы используете этот метод с анимацией «ДА», тогда нет необходимости использовать другую анимацию bcoZ, этот метод имеет свою собственную анимацию :) – iPatel

Смежные вопросы