UIScrollView decelerating
@property(nonatomic, readonly, getter=isDecelerating) BOOL decelerating
Discussion of [UIScrollView decelerating]
The returned value is YES if user isn't dragging the content but scrolling is still occurring.
UIScrollView decelerating example.
Assign a delegate to your UIScrollView object if you have not already done so.
In your delegate's .m implementation file, add the following lines of code:
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
[scrollView setContentOffset:scrollView.contentOffset animated:YES];
}
In your delegate's .m implementation file, add the following lines of code:
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
[scrollView setContentOffset:scrollView.contentOffset animated:YES];
}
Example of [UIScrollView decelerating].
if (self.tableView.isDecelerating) {
NSArray *paths = [self.tableView indexPathsForVisibleRows];
[self.tableView scrollToRowAtIndexPath:[paths objectAtIndex:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
NSArray *paths = [self.tableView indexPathsForVisibleRows];
[self.tableView scrollToRowAtIndexPath:[paths objectAtIndex:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
UIScrollView decelerating example.
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
[self.content setDecelerationRate:UIScrollViewDecelerationRateNormal];
NSLog(@"scrollviewwillbegindecelerating %f", self.content.decelerationRate);
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSLog(@"scrollviewdidenddeceleration");
}
[self.content setDecelerationRate:UIScrollViewDecelerationRateNormal];
NSLog(@"scrollviewwillbegindecelerating %f", self.content.decelerationRate);
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSLog(@"scrollviewdidenddeceleration");
}