Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I disable / edit the automatic jump-to-top scroll when tapping status bar?

I'm using an app with a tableView that auto-scrolls downward, so tapping the status bar, which would normally jump to the top of the table, causes problems (it begins scrolling but if the auto-scroll ticks, it stops and leaves it somewhere in the middle).

I'd either like to disable it, or at least have shove some code in when it's tapped to temporarily pause the timer and then resume it when it reaches the top.

Are there any means of achieving either of these things?

like image 831
Luke Avatar asked Mar 13 '13 20:03

Luke


1 Answers

UIScrollView (and UITableView as a subclass of it) has scrollsToTop property which defaults to YES, making it scroll to top when status bar is tapped. All you have to do is set it to NO.

However, please keep in mind that iOS users might expect this behavior, so turning it off may not be the best idea from user experience standpoint. You can also leave it as YES and return NO from -scrollViewShouldScrollToTop: delegate method if you only need it disabled at specific times.

Actually, handling it via delegate might be a perfect fit for your case:

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
{
    // disable timer
    return YES;
}

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
    // re-enable timer
}
like image 185
Filip Radelic Avatar answered Oct 02 '22 22:10

Filip Radelic