scrollViewDidScroll never called

2019-02-06 02:20发布

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.

2条回答
仙女界的扛把子
2楼-- · 2019-02-06 02:40

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

theScrollView.delegate = self;
查看更多
闹够了就滚
3楼-- · 2019-02-06 02:44

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.

查看更多
登录 后发表回答