I’m not sure how this works. I was following this post: check if UIWebView scrolls to the bottom
I want to know when the scrollViewScrolls to do some custom things. I subclasses UIWebView. All I did was this so far:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[super scrollViewDidScroll:scrollView];
NSLog(@"%s", __FUNCTION__);
}
It crashes on the [super scrollViewDidScroll:scrollView] method. When I delete that line, it works fine. I don’t want to take away the superclass’ implementation of this method. I just wanted to add some custom functionality to it (place a toolbar above the webview like the Facebook app). Is there a reason why this is crashing? Thanks.
Are you sure
UIWebViewactually implements that delegate method? Because it sounds like it probably doesn’t. You should use the following construct when overriding optional delegate methods like this:Not only will this avoid calling super if the superclass doesn’t actually implement the method, but it will automatically start calling super if an OS update ever causes the superclass to start responding to the method.
Also note, you need to hardcode the superclass name (e.g.
UIWebView). Trying to use either[self superclass]or[super class]is going to give you the wrong results.