本文介绍了弹跳UIScrollView - 暗示还有更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个带有滚动视图的应用程序。没有立即显示内容更多,并且没有滚动指示器(滚动视图被分页)。

I'm developing an app with a scroll view in it. It's not immediately obvious that there's more content, and there's no scroll indicator (scroll view is paged).

所以,为了给用户一个'嘿,这里有一些东西......',我想让滚动视图在启动时做一个微妙的反弹 - 然后再向下。我试过这个:

So, to give the user a 'hey, there's something down here...', I would like to have the scroll view do a subtle bounce - down then up - on launch. I've tried this:

- (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];
}

然而,这段代码使得视图在两个中间位置被卡住页面。

However, this code makes the view get 'stuck' at about halfway between two pages.

任何帮助?

推荐答案

创意1 :你需要关闭分页,为弹跳设置动画,然后重新打开分页。

Idea 1: You need to turn off paging, animate the bounce, and turn the paging back on.

构思2 :你的第二步是太快了:

Idea 2: Your second move is coming way too soon:

scheduledTimerWithTimeInterval:0.01

尝试更长的时间间隔!我会从 0.4 开始。

Experiment with longer time intervals! I would start with 0.4.

创意3 :为什么不使用 flashScrollIndicators 而不是弹跳?这正是它的用途!

Idea 3: Instead of your bounce, why not use flashScrollIndicators? This is exactly what it is for!

这篇关于弹跳UIScrollView - 暗示还有更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 01:44