scrollViewDidScroll never called

2019-02-06 02:00发布

问题:

I have a Scrollview within View. I want to use the function scrollViewDidScroll to check and update the arrows (left right).

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    NSLog(@"Did scroll");
    [self updateButtons];
}

It seems scrollViewDidScroll won't be called when I scroll left or right. I searched everything but didn't found a solution.

Hope someone has a solution.

回答1:

The typical error is that "one does not simply set the delegate of a view". What you have probably forgotten is

theScrollView.delegate = self;


回答2:

I had this "symptom" as well and lost about 2 hours of my life on it. I clearly had the delegate set correctly...but I did NOT know about setting the contentSize property on the scroll view. -.-

If you don't set that property, then the scroll view doesn't think there is anything to scroll to, and therefore will NOT trigger the expected scroll view methods.