Jordi Kroon
Jordi Kroon

Reputation: 2597

scrollViewDidScroll never called

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.

Upvotes: 16

Views: 15383

Answers (3)

PDG
PDG

Reputation: 369

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

Upvotes: 0

ghostatron
ghostatron

Reputation: 2650

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.

Upvotes: 25

user529758
user529758

Reputation:

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

theScrollView.delegate = self;

Upvotes: 55

Related Questions