16

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.

Jordi Kroon
  • 2,607
  • 3
  • 31
  • 55

3 Answers3

55

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

theScrollView.delegate = self;
25

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.

ghostatron
  • 2,620
  • 23
  • 27
0

If you defined your UIScrollView in the xib, you can simply do a Ctrl-Drag, from the ScrollView to the Files Owner and set the delegate that way. Probably the easiest way to do it.enter image description here

PDG
  • 349
  • 3
  • 10