【问题标题】:Add a UIRefreshControl below a UITableView [duplicate]在 UITableView 下方添加 UIRefreshControl [重复]
【发布时间】:2013-12-30 10:36:18
【问题描述】:

有没有办法在 UITableView 下添加 UIRefreshControl?我创建了一个preview 我想要实现的目标。

【问题讨论】:

标签: ios uitableview uirefreshcontrol


【解决方案1】:

这些不会提供 UIRefresh 控件,但您可以将它们添加到屏幕底部

在你的标题下面声明

  UIActivityIndicatorView                             *spinner;

在您的实现中在 ViewDidLoad 中初始化相同的内容

spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
    [spinner stopAnimating];
    spinner.hidesWhenStopped = NO;
    spinner.frame = CGRectMake(0, 0, 320, 44);
    self.tableviewName.tableFooterView = spinner;

添加这些会在tableview Scrolled时调用

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

    CGPoint offset = aScrollView.contentOffset;
    CGRect bounds = aScrollView.bounds;
    CGSize size = aScrollView.contentSize;
    UIEdgeInsets inset = aScrollView.contentInset;
    float y = offset.y + bounds.size.height - inset.bottom;
    float h = size.height;

    float reload_distance = 50;
    if(y > h + reload_distance) {
        NSLog(@"load more data");
        [spinner startAnimating];
    }
}

希望对你有所帮助!

【讨论】:

  • 很好的解决方案!我正在使用它,稍作修改:[spinner startAnimating]; spinner.hidesWhenStopped = YES;我检测到我是否在表格视图的真正末端,并且有 [spinner stopAnimating];
  • 解决方案很好,但是在隐藏活动指示器表后我有一个查询没有向下滚动。如果您对此也有任何解决方案,请告诉我。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-22
  • 2013-07-05
  • 1970-01-01
  • 1970-01-01
  • 2013-09-25
  • 2015-07-30
  • 1970-01-01
相关资源
最近更新 更多