iOS 10.0 UIRefreshControl not showing indicator

dogwasstar picture dogwasstar · Sep 14, 2016 · Viewed 9.2k times · Source

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 beginRefreshing]

The above code is called inside the viewDidLoad cause the table is loading some data initially. The spinner works fine if I perform a pull down to refresh after the initial refresh. The title shows up but not the spinner.

Cant seem to solve this problem. It works fine on iOS 9.3.2 but not on iOS 10.

Here is the code I am using currently.

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupView];
    [self customSetup];
    self.refreshControl = [[UIRefreshControl alloc] init];
    self.refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"Updating Discounts..."];
    [self.refreshControl addTarget:self action:@selector(reloadDeals) forControlEvents:UIControlEventValueChanged];
    [self.refreshControl beginRefreshing];
    [self.tableView setContentOffset:CGPointMake(0, -self.refreshControl.frame.size.height) animated:YES];
}

Thanks for your help in advance

Answer

weirdyu picture weirdyu · Oct 10, 2016

before the code:

[refreshControl beginRefresh]

insert the code:

[refreshControl layoutIfNeeded]