Okay, so I did all the research for this issue but none of the existing solutions seem to address my problem, so here it is:
- I have a custom class that extends UIScrollView (and contains a UIView)
- I'd like to override the scrollViewDidScroll method from UIScrollViewDelegate (but not all the methods)
I have already tried implementing the code from this issue: How to subclass UIScrollView and make the delegate property private but for some reason, it doesn't do anything (the custom method that was overridden never gets called). I also know that you don't have to implement all the methods from UIScrollViewDelegate if you create a custom delegate class that implements the protocol (as per iPhone: Do I need to implement all methods for UIScrollViewDelegate (or any delegate)) - but when I do this:
MyScrollViewDelegate.h
@interface MyScrollViewDelegate: NSObject <UIScrollViewDelegate>
-(void)scrollViewDidScroll:(UIScrollView *)scrollView;
@end
MyScrollViewDelegate.m
@implementation MyScrollViewDelegate
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"Custom scrollViewDidScroll called.");
// -- some more custom code here --
// ...
}
@end
In the subclass which extends UIScrollView
// this scrollview is initiated by the NIB
- (void)awakeFromNib
{
...
[self setDelegate:[[MyScrollViewDelegate alloc] init]];
}
But while it compiles and runs, when I try to scroll the scrollable view, it crashes with EXC_BAD_ACCESS and a cryptic "(lldb)" message in the debug console.
So I'm bit at a loss here what to do.