Skip to content

如果计算里这么写,从评论到网页可以马上回到评论页里(之前的版本是回到网页之后马上回评论是不行的) #1

@Lafree317

Description

@Lafree317

之前的版本是回到网页之后马上回评论是不行的
根据你的代码临时更改了一下,没来得及优化.谢谢你的库,对我很有帮助

#pragma mark scrollview delegate (计算contentOffset的值,根据上下距离来决定bounces)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

     CGFloat top = scrollView.contentOffset.y;
     if (scrollView == _webView.scrollView) {
        if (top >= _webView.scrollView.contentSize.height - self.view.height - 50) {
            state = 2;
        }else{
            state = 1;
        }
        if (top > 30) {
            _webView.scrollView.bounces = NO;
        }else{
            _webView.scrollView.bounces = YES;
        }

    }else if([scrollView isKindOfClass:[UITableView class]]){
        if (top > (_tableView.contentSize.height - viewHeight - 10)) {
            _tableView.bounces = YES;
        }else{
            _tableView.bounces = NO;
        }
        if (top <= 0) {
            state = 1;
        }else{
            state = 2;
        }
    }
    NSLog(@"当前Stats%d,Class:%@,偏移量:%f",state,[UITableView class],top);
    _tableView.scrollEnabled = (state == 2);
    _webView.scrollView.scrollEnabled = (state == 1);

    if ((state == 1 && top == 0) (state == 2 && top == (_webView.scrollView.contentSize.height - self.view.height - 50))){
        _tableView.scrollEnabled = YES;
        _webView.scrollView.scrollEnabled = YES;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions