【问题标题】:Load table at bottom instead of top在底部而不是顶部加载表格
【发布时间】:2015-03-09 22:36:17
【问题描述】:

我试图在滚动视图的底部而不是顶部加载表格。我使用了这段代码,但它正在加载顶部的表格。

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    float bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
    if (bottomEdge >= scrollView.contentSize.height) {
        if ((isloading = true)) {
            pageno= pageno+1;
            [self fetchdata];
            [self.tableview reloadData];
        }
    }
}

【问题讨论】:

  • 在数据数组的末尾添加数据
  • 显示获取数据的代码
  • 这里不需要使用scrollViewDidEndDecelerating方法。在UITableView 中搜索加载更多概念的答案将是您的最佳匹配。喜欢 - stackoverflow.com/questions/20269474/…

标签: ios objective-c


【解决方案1】:

UITableView 继承自 UIScrollView。可以使用属性contentSize获取内容的高度,然后可以使用

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated

或者,如果你知道哪一行是你的最后一行

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated

Apple Documentation

【讨论】:

    猜你喜欢
    • 2019-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 2023-02-07
    • 1970-01-01
    相关资源
    最近更新 更多