ios - UItableView加载数据10 滚动10条记录

标签 ios uitableview ios7

我正在从网络服务获取数据,并且必须在 UITableView 中显示它。但这里的条件是我最初只能显示 10 条记录,然后一旦用户向下滚动我必须加载更多记录,它也包含图像。我尝试搜索它但没有得到任何有用的答案。

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { }

显示该值,但我如何最初只获取 10 条记录,然后基于滚动获取其他记录。请提供一些要点或示例代码

最佳答案

在您的后端链接中保留一个“索引”字段。当index=0时,从backed中获取10条记录,然后将index增加到1,获取另外10条记录,依此类推...

保留代码在滚动最后的tableView时也调用链接,

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{

    NSInteger currentOffset = scrollView.contentOffset.y;
    NSInteger maximumOffset = scrollView.contentSize.height- scrollView.frame.size.height;
    if (maximumOffset - currentOffset <= 0) {
        index =index +1;
        // Call your link here
    }
}

关于ios - UItableView加载数据10 滚动10条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22856311/

相关文章:

android - 如何使用外部视频播放器启动视频网址?

ios - 如何知道 View Controller 是否将呈现为弹出窗口或模式?

ios - '-[__NSDictionaryI 长度] : unrecognized selector sent to instance' - trying to figure out why

ios - UISearchBar AutoLayout ios7 错误?

uiviewcontroller - IOS7 的滑动 View Controller 菜单和状态栏问题

ios - Testflight 不允许使用 iOS 8.1 SDK 编译的 iOS 7.1 应用程序安装在 iOS 7.1.2 iPhone 上

ios - 在 swiftUI 中的 View 数组之间切换

ios - 获取字符串的某些部分

ios - 将 superView 拖动到特定阈值后启用滚动 UITableView

ios - TableView 连续并导致意外返回 nil