I have a UIScrollView
, created programmatically, inside of a UIView
. What do I need to do to ensure that I can use the delegate method scrollViewDidEndDecelerating
?
Here's what I have set up, please assume that within the UIScrollView
, that there are three UIImageViews
. When the page first loads, I am looking at the center UIImageView
and I can scroll once backwards or once forwards. The reason why I need this delegate method is because I intend to use it to calculate which UIImageView
I am currently looking at.
ViewController.h
@interface ViewController : UIViewController <UIScrollViewDelegate>
ViewController.m
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
scrollView.pagingEnabled = YES;
[self.view addSubview: scrollView];
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidEndDecelerating");
}
Add
scrollView.delegate = self
after the scroll view initialization.