Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bounce UIScrollView - hint that there's more

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.

Any help?

like image 985
Undo Avatar asked Mar 25 '23 04:03

Undo


1 Answers

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

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

scheduledTimerWithTimeInterval:0.01

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

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

like image 84
matt Avatar answered Apr 06 '23 07:04

matt