UIScrollView scrollViewDidEndDecelerating does not fire

I have UIScrollView

one created programmatically inside UIView

. What do I need to do to make sure I can use the delegate method scrollViewDidEndDecelerating

?

This is what I installed, suppose UIScrollView

there are three UIImageViews

. When the first page loads, I look at the center UIImageView

and I can scroll back once or forward once. The reason I need this delegate method is because I intend to use it to calculate which one 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");
}

      

+3


source to share


2 answers


Add to

 scrollView.delegate = self

      



after initializing the scroll view.

+1


source


In your delegate method, you can test each uiimageview center to see which one corresponds to the uiview center. This is the uiimageview you are looking at.



0


source







All Articles