scrollViewDidScroll never called
Asked Answered
P

3

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.

Pitfall answered 30/12, 2012 at 23:45 Comment(0)
V
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;
Villainous answered 31/12, 2012 at 0:16 Comment(0)
S
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.

Saviour answered 16/8, 2013 at 18:59 Comment(1)
Wow this is mean. Was exactly my problem. Thx.Declarant
E
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

Evanthe answered 15/6, 2023 at 18:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.