The answer to this is probably right under my nose, but I am not seeing it. Maybe someone here could help.
I have a scrollView that allows for vertical scrolling. I set it up:
[clefScrollView addSubview:clefView];
[clefScrollView setContentSize:CGSizeMake(clefView.frame.size.width, clefView.frame.size.height)];
clefScrollView.showsVerticalScrollIndicator = YES;
clefScrollView.showsHorizontalScrollIndicator = NO;
clefScrollView.delegate = self;
I have the following methods included in the same file, in order to support the UIScrollViewDelegate protocol:
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
NSLog(@"%f %f", scrollView.contentOffset.y, scrollView.contentSize.height);
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidEndDecelerating");
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidEndScrollingAnimation");
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidScroll");
}
In addition, the .h file for my class includes the protocol:
@interface ClefNotesViewController : UIViewController <UIActionSheetDelegate,UIScrollViewDelegate,DoneWithVCDelegate> {
The problem is that no matter what, the following two are never called:
-scrollViewDidEndDecelerating
-scrollViewDidScroll
The other two methods do get called in response to different events. Given that two of the protocol methods are getting called, I assume that I have correctly set the delegate to my self. So, what is the problem?
Thanks!
Update: I found the problem, although haven't still figured out how to resolve it. My class spans two files. In the second file, a different scrollView is implementing -scrollViewDidEndDecelerating -scrollViewDidScroll
THe question is, how can I define two different sets of methods for two different UIScrollViews, in the same class?
I could try to handle two scrollViews with the same delegate methods, but that's ugly since I won't be able to keep each set of delegates with the scrollView's file. I could also split my class. Is there another way?