调用beginRefreshing并且contentOffset为0时,UIRefreshControl没有显示多刺 [英] UIRefreshControl not showing spiny when calling beginRefreshing and contentOffset is 0

查看:802
本文介绍了调用beginRefreshing并且contentOffset为0时,UIRefreshControl没有显示多刺的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用 beginRefreshing时,我无法看到加载微调器

I am not able to see the loading spinner when calling beginRefreshing

[self.refreshControl beginRefreshing];

我的UITableViewController子类使用UIRefreshControl

My UITableViewController subclass uses a UIRefreshControl

// refresh
    UIRefreshControl * refreshControl = [UIRefreshControl new];
    [refreshControl addTarget:self action:@selector(refreshTableView) forControlEvents:UIControlEventValueChanged];
    self.refreshControl = refreshControl;

它与用户交互完美配合(当用户放下桌子时),然后微调器是可见。

It is working perfectly with user interaction (when the user drops the table down), then the spinner is visible.

但是当我在viewDidLoad上调用 beginRefreshing 时,我看不到微调器(仅当我拖动时)下表)。

But when i call beginRefreshing on viewDidLoad, I don't see the spinner (only when i drag the table down).

注意:


  • self.refreshControl引用是对的

  • self.refreshControl reference is right

在beginRefreshing之后没有立即调用reloadData或endRefreshing,但是有很长的时间延迟(通过网络加载数据),所以我没有取消beginRefreshing。

reloadData or endRefreshing is not called immediately after beginRefreshing, but there is a long time delay (loading data through network), so I am not canceling the beginRefreshing.

编辑:
这只发生在 contentOffset tableView 的属性为0,我调用 [self.refreshControl beginRefreshing] 。错误? Feauture?

Edit : This only happens when the contentOffset property of the tableView is 0 and i call [self.refreshControl beginRefreshing]. Bug? Feauture?

推荐答案

对我来说这看起来像个错误,因为它只在 contentOffset tableView 的属性是 0

It looks like a bug to me, because it only occures when the contentOffset property of the tableView is 0

我用以下代码修改了它(UITableViewController的方法):

I fixed that with the following code (method for the UITableViewController) :

- (void)beginRefreshingTableView {

    [self.refreshControl beginRefreshing];

    if (self.tableView.contentOffset.y == 0) {

        [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^(void){

            self.tableView.contentOffset = CGPointMake(0, -self.refreshControl.frame.size.height);

        } completion:^(BOOL finished){

        }];

    }
}

这篇关于调用beginRefreshing并且contentOffset为0时,UIRefreshControl没有显示多刺的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆