Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems when overriding scrollViewDidScroll, but not all the other methods of UIScrollViewDelegate
    text
    copied!<p>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:</p> <ul> <li>I have a custom class that extends UIScrollView (and contains a UIView)</li> <li>I'd like to override the scrollViewDidScroll method from UIScrollViewDelegate (but not all the methods)</li> </ul> <p>I have already tried implementing the code from this issue: <a href="https://stackoverflow.com/questions/9978279/how-to-subclass-uiscrollview-and-make-the-delegate-property-private">How to subclass UIScrollView and make the delegate property private</a> 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 <a href="https://stackoverflow.com/questions/6644630/iphone-do-i-need-to-implement-all-methods-for-uiscrollviewdelegate-or-any-dele">iPhone: Do I need to implement all methods for UIScrollViewDelegate (or any delegate)</a>) - but when I do this:</p> <p><strong>MyScrollViewDelegate.h</strong></p> <pre><code>@interface MyScrollViewDelegate: NSObject &lt;UIScrollViewDelegate&gt; -(void)scrollViewDidScroll:(UIScrollView *)scrollView; @end </code></pre> <p><strong>MyScrollViewDelegate.m</strong></p> <pre><code>@implementation MyScrollViewDelegate -(void)scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@"Custom scrollViewDidScroll called."); // -- some more custom code here -- // ... } @end </code></pre> <p><strong>In the subclass which extends UIScrollView</strong></p> <pre><code>// this scrollview is initiated by the NIB - (void)awakeFromNib { ... [self setDelegate:[[MyScrollViewDelegate alloc] init]]; } </code></pre> <p>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.</p> <p>So I'm bit at a loss here what to do.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload