Objective-C UIWebView添加脚视图

Posted Vijay的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Objective-C UIWebView添加脚视图相关的知识,希望对你有一定的参考价值。

- (void)addObserverForWebViewContentSize{
    [self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:0 context:nil];
}
- (void)removeObserverForWebViewContentSize{
    [self.webView.scrollView removeObserver:self forKeyPath:@"contentSize"];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    //在这里边添加你的代码
    [self layoutCell];
}
//设置footerView的合理位置
- (void)layoutCell{
    //取消监听,因为这里会调整contentSize,避免无限递归
    [self removeObserverForWebViewContentSize];
    CGSize contentSize = self.webView.scrollView.contentSize;

    self.btnView.frame = CGRectMake(0, contentSize.height, ScreenWidth, 60);
      [self.webView.scrollView addSubview:self.btnView];
    self.webView.scrollView.contentSize = CGSizeMake(contentSize.width, contentSize.height + 60);
    //重新监听
    [self addObserverForWebViewContentSize];
}
-(AgreeBtnCell *)btnView{

    if (!_btnView) {
        _btnView = [AgreeBtnCell cell];
    }
    return _btnView;
}

 

以上是关于Objective-C UIWebView添加脚视图的主要内容,如果未能解决你的问题,请参考以下文章