为什么UIWebView实例不调用scrollViewDidScroll? [英] Why does a UIWebView instance not call scrollViewDidScroll?

查看:141
本文介绍了为什么UIWebView实例不调用scrollViewDidScroll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS文档说, UIWebView 类符合UIScrollViewDelegate。但是UIWebView实例不会调用其控制器的 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];

成功调用

webViewDidFinishLoad 。控制器实现委托,UIWebViewDelegate和UIScrollViewDelegate,如下所示:

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

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

浏览SO会导致类别解决方案

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

该类别方法基本相同:调用委托的scrollViewDidScroll方法。那么为什么第一种方法不起作用?

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

推荐答案

我的猜测是你只为UIWebView设置了委托。
尝试设置scrollView的委托。

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

webView.scrollView.delegate = self

它应该没问题。

这篇关于为什么UIWebView实例不调用scrollViewDidScroll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆