Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollToRowAtIndexPath:atScrollPosition:animated scrolling too slow

Based on the page change of a paged UIScrollView, I'm calling scrollToRowAtIndexPath:atScrollPosition:animated to the table specifics for that page that's in display.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat pageWidth = self.scrollView.frame.size.width;
    int page = floor((self.scrollView.contentOffset.x - pageWidth/2)/pageWidth)+1;
    self.pageControl.currentPage = page;
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:page];
    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

However, the animation of the automatic scrolling is happening too slow. Is there a way to make this animation more snappy?

like image 444
Oscar Swanros Avatar asked Nov 20 '25 18:11

Oscar Swanros


1 Answers

A fast solution might be:

[UIView animateWithDuration:aSmallValue animations:^{
        [self.tableView scrollToRowAtIndexPath:indexPath
                              atScrollPosition:UITableViewScrollPositionTop 
                                      animated:NO];
}];
like image 61
danypata Avatar answered Nov 22 '25 08:11

danypata



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!