Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollViewDidScroll delegate is invoking automatically

I am using scrollViewDidScroll delegate in my application.

But, many times, even though I dint start scrolling, this delegate is getting invoked which is creating a lot of problem. I heard that even when contentSize for a particular scroll view is set then at that time also this delegate i.e., scrollViewDidScroll will invoke.

What are the different scenarios in which this delegate gets invoked. What are the steps to control this?

Can I set any parameter to handle this?

like image 590
Bharath Avatar asked Jul 25 '12 18:07

Bharath


2 Answers

Hi Guys its very old question, however, if you wanna know if the scrollDidScroll was triggered manually(through finger) or its due to other event like didSelect or setContentOffset, use the UIScrollView.isTracking property.

like image 122
user1968991 Avatar answered Oct 03 '22 20:10

user1968991


To prevent scrollDidScroll: from firing automatically when the view is loaded and adjusted, I waited to add my UIScrollView delegate until after all the views load using viewDidLayoutSubviews. It is working well for me.

- (void)viewDidLayoutSubviews {
    // add table view delegate after the views have been laid out to prevent scrollViewDidScroll
    // from firing automaticly when the view is adjusted on load, which makes the tab bar disappear 
    self.tableView.delegate = self;
} 
like image 25
Sev Avatar answered Oct 03 '22 18:10

Sev