Reputation: 592
I've a strange issue.Where I have a ScrollView and ContentOffset was already Set to it. And I've made a Condition in its Delegate by the below Code.
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(scrollOffsetY > 90 && scrollOffsetY < 150) {
NSLog(@"ContentOffset===>%f",ContentOffset);
}
}
The Condition Which I've Written Works and Get into it only When I Scroll the scrollview Slowly. If I Scroll Faster. It Doesn't Getting into my Loop.
How Do I fix this ? and Get the Exact Value when the Condition is True ?
Upvotes: 1
Views: 619
Reputation: 1245
UIScrollView doesn't call delegate for every scrolled pixel. Instead it calls it on every frameshot will be displayed. When you scroll quickly, the scroll view may skip the area you want to check. If you need to catch the moment when the specified area if on the screen you may add a variable to store the previous offset and add a condition like this:
if (previousScrollOffsetY > 150 && scrollOffsetY < 90) || (previousScrollOffsetY < 90 && scrollOffsetY > 150) {
NSLog(@"Skipped area")
}
previousScrollOffsetY = scrollOffsetY;
Upvotes: 1