美文网首页ios 知识点
TableView加载更多设置

TableView加载更多设置

作者: PZcoder | 来源:发表于2016-11-18 14:37 被阅读10次

在需要上拉加载更多的tableview上设置footerview提示上拉加载更多,
在tableview滑动停止时回调以下方法,在回调时判断tableview及设置加载更多的网络请求操作。

注意:此处所写方法适用于多个tableview的判断。

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    //判断tableview的位置
    BOOL table = self.lastTableView.contentOffset.y  > self.lastTableView.contentSize.height - self.lastTableView.frame.size.height - 2;
    
    //判断更多按钮标题
    BOOL moreButton = ![moreBtn.titleLabel.text isEqualToString:@"加载中..."];
    
    if (table && !loadMoreView.hidden && moreButton && self.lastTableView.tableFooterView)
    {
        if([StaticTools checkNetWork] == 0)
        {
            [super internetConnectFailed:0];
            return;
        }
        
        [moreBtn setTitle:@"加载中..." forState:UIControlStateNormal];
        moreActivityIV.hidden = NO;
        [moreActivityIV startAnimating];
        
        //加载更多资讯列表
        if (self.lastTableView.tag == Tag_Daily)
        {
            [self getDailyCommentsListWithPageNo:self.pageMtbDict[currentIdStr]];
        }
        else if (self.lastTableView.tag == Tag_VideoHSZJ)
        {
            [self getVideoList];
        }
        else if (self.lastTableView.tag == Tag_Live)//直播
        {
            [self getVideoListWithFirst:NO];
        }
        else
        {
            [self getInformationListWith:currentIdStr pageNo:self.pageMtbDict[currentIdStr]];
        }
    }
}

相关文章

网友评论

    本文标题:TableView加载更多设置

    本文链接:https://www.haomeiwen.com/subject/lqzjpttx.html