iOS 10.0 UIRefreshControl not showing indicator

前端 未结 8 1349
庸人自扰
庸人自扰 2020-12-29 06:02

I am using a UITableView Which has a Pull down to refresh function but the spinner for pull down to refresh is not showing up when I call the [self.refreshControl beginRefre

相关标签:
8条回答
  • 2020-12-29 06:32

    Delaying call to refresh in viewDidLoad worked for me:

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.refreshControl beginRefreshing];
    });
    
    0 讨论(0)
  • 2020-12-29 06:32

    In iOS10, we should add the UIRefreshControl using setRefreshControl of UITableView or UICollectionView.

    if([self.tableView respondsToSelector:@selector(setRefreshControl:)]) {
        [self.tableView setRefreshControl:self.refreshControl];
    }
    else {
        [self.tableView addSubview:self.refreshControl];
    }
    [self.refreshControl layoutIfNeeded];
    [self.refreshControl beginRefreshing];
    
    0 讨论(0)
  • 2020-12-29 06:34

    I was only able to fix this by calling, from viewDidLoad():

    refreshControl.layoutIfNeeded()
    
    0 讨论(0)
  • 2020-12-29 06:41

    Same as @jpros answer but in swift

    if #available(iOS 10.0, *) {
        tableView.refreshControl = refreshControl
    } else {
        tableView.addSubview(refreshControl)
    }
    refreshControl.layoutIfNeeded()
    refreshControl.beginRefreshing()
    
    0 讨论(0)
  • 2020-12-29 06:45

    This is a known and reported bug in iOS 10.

    Radar rdar://27468436

    I'm not sure if there are any workarounds.

    0 讨论(0)
  • 2020-12-29 06:46

    You need to call [self.view layoutIfNeeded] to fix it in iOS 10. For my case it was enough to put the call to viewDidLoad (I was using storyboard in that project). For other cases viewWillAppear fits better.

    - (void)viewDidLoad
      {
       [super viewDidLoad];
       [self.view layoutIfNeeded];
       ...
    
    0 讨论(0)
提交回复
热议问题