0
votes

I used the following code to init the new UIScrollView:

    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scroll.showsHorizontalScrollIndicator = NO;
    scroll.showsVerticalScrollIndicator = NO;

Then I added 3 UIView instance into the scrollView instance.

But When I use it's delegate method - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView and - (void)scrollViewDidScroll:(UIScrollView *)scrollView

both of them did not work, I typed a NSLog Method to catch the logs in GDB if the functions calld.

What's going on?

2
Have you set the delegate class correctly? - Alexander

2 Answers

2
votes

add your self as delegate of the UIScrollView

scroll.delegate = self;
0
votes

you can add this code in viewdidload

ScrollView.delegate = self;

or link from storyboard/xib

and remember to add UIScrollViewDelegate after interface

@interface ViewController ()<UIScrollViewDelegate>

@end