弹跳UIScrollView – 暗示还有更多
我正在开发一个带有滚动视图的应用程序。 不是很明显,有更多的内容,并没有滚动指标(滚动视图是分页)。
所以,为了给用户一个'嘿,这里有什么东西……',我想让这个滚动视图在发布的时候做一个微妙的反弹。 我试过这个:
- (void)viewDidLoad .... [NSTimer scheduledTimerWithTimeInterval:0.8 target:self selector:@selector(bounceScrollView) userInfo:nil repeats:NO]; } - (void)bounceScrollView { [self.verticalScrollViews[0] scrollRectToVisible:CGRectMake(0, 600, 1, 1) animated:YES]; [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(_unbounceScrollView) userInfo:nil repeats:NO]; } - (void)_unbounceScrollView { [self.verticalScrollViews[0] scrollRectToVisible:CGRectZero animated:YES]; }
但是,这段代码使视图在两页之间的中间处“卡住”。
任何帮助?
想法1 :您需要closures分页,使反弹animation,然后打开分页。
想法2 :你的第二招即将来临:
scheduledTimerWithTimeInterval:0.01
尝试更长的时间间隔! 我会从0.4
开始。
想法3 :为什么不使用flashScrollIndicators
而不是反弹? 这正是它的目的!
我在使用NSTimer时遇到内存问题。 这就是为什么我使用另一个解决scheme的scrollView预览。
[UIView animateWithDuration:1.0 delay:0.00 options:UIViewAnimationOptionCurveEaseInOut animations:^{ _scrollView.contentOffset = CGPointMake(200,0); } completion:^(BOOL finished){ [UIView animateWithDuration:1.0 delay:0.00 options:UIViewAnimationOptionCurveEaseInOut animations:^{ _scrollView.contentOffset = CGPointMake(0,0); } completion:^(BOOL finished){ } ]; } ];