Make the UITableView scroll from top to bottom for a given period of time?

I'm trying to get mine UITableView

to scroll down slowly at a constant speed that I can point out. I've used it scrollToRowAtIndexPath

, but regardless of whether I choose to animate it, it's almost instant movement. I am looking at something that is moving much slower.

I was really wondering if I could do something with the UIView animation block moving one indexPath.row

at a time, but since my cells are at different heights this will result in uneven animation speed.

Any other ways I can do this?

+3


source to share


3 answers


I got it with this one.

[NSTimer scheduledTimerWithTimeInterval: 0.025 target:self selector:@selector(scrollTableView) userInfo:nil repeats:YES];

      



AND..

- (void) scrollTableView {

    float w = 1;

    CGPoint scrollPoint = self.tableView.contentOffset;
    scrollPoint.y = scrollPoint.y + w;
    if (scrollPoint.y >= self.tableView.contentSize.height - (self.tableView.frame.size.height - 100)  || scrollPoint.x <= -self.tableView.frame.size.height + 924) {
    w *= -1;
    }
    [self.tableView setContentOffset: scrollPoint animated: NO];
}

      

+3


source


You can always decrease the contentOffset y axis over time.



0


source


Here you go, buddy. Just change animateWithDuration to higher seconds like 1 or 1.5 to see if it achieves the desired effect. Make sure to include the QuartzCore library #import <QuartzCore/QuartzCore.h>

in your * .m file as well. It's as easy as

-(IBAction)modeTableSlowly
{

    [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{

            //here tblSimpleTable2 is tableView
            [tblSimpleTable2 setFrame:CGRectMake(183, 56, 137, 368)];

    } completion:nil];

}

      

0


source







All Articles