zoukankan      html  css  js  c++  java
  • 加载更多时,判断tableView快要滑动到底部的时候在去请求更多数据的公式

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        /*
         // 判断是否需要加载更多
         // 判断等于0可以防止没有数据就显示加载更多控件
         // 判断底部视图是否隐藏可以防止重复加载
         if (self.statuses.count == 0 ||
         self.tableView.tableFooterView.hidden == NO) {
         return;
         }
         // 如果当前的偏移位等于 contentSize.height + contentInset.bottom - scrollView.height; 那么就需要加载更多数据
         // 如果当前的偏移位等于 scrollView能够滚动的高度 + 底部额外的扩展区域 - scrollView的高度, 那么就需要加载更多数据
         CGFloat offsetY = scrollView.contentSize.height + scrollView.contentInset.bottom - scrollView.height;
         if (scrollView.contentOffset.y >= offsetY) {
         self.tableView.tableFooterView.hidden = NO;
         DDLogDebug(@"加载更多数据");
         [self loadMoreStatuses];
         }
         */
        
        CGFloat offsetY = scrollView.contentSize.height + scrollView.contentInset.bottom - scrollView.height;
        if (scrollView.contentOffset.y >= offsetY)
        {
            self.tableView.tableFooterView.hidden = NO;
            
            NSLog(@"加载更多");
        }
    }
  • 相关阅读:
    java8 Stream排序字段为空排序方法
    SpringBoot使用token简单鉴权的具体实现方法
    性能调优
    TestNG最简单的测试
    TestNG异常测试
    TestNG中如何执行测试
    TestNG的基本注解
    TestNG介绍
    TestNG 环境搭建
    python第四课笔记
  • 原文地址:https://www.cnblogs.com/fs-ios/p/4998089.html
Copyright © 2011-2022 走看看