Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does a UIWebView instance not call scrollViewDidScroll?

iOS documention says, that the UIWebView class conforms to UIScrollViewDelegate. But an UIWebView instance does not call the scrollViewDidScroll method of its controller. The delegate is set just right by

[webView setDelegate:self];

and webViewDidFinishLoad is called successfully. The controller implements both delegates, UIWebViewDelegate and UIScrollViewDelegate, like this:

@interface WebviewController : UIViewController<UIWebViewDelegate, UIScrollViewDelegate>{
    UIWebView *webView;
}

Browsing SO leads to that category solution:

@implementation UIWebView(CustomScroll)
- (void) scrollViewDidScroll:(UIScrollView *)scrollView{
    [self.delegate scrollViewDidScroll: scrollView];
}
@end

That category approach does basically the same: Calling the delegate's scrollViewDidScroll method. So why does the the first approach not work?

like image 510
alex Avatar asked Aug 23 '12 14:08

alex


1 Answers

My guess is you set up delegate only for UIWebView. Try setting delegate of scrollView.

webView.scrollView.delegate = self

it should be ok.

like image 197
pawelropa Avatar answered Sep 30 '22 19:09

pawelropa