Pull to refresh: screen disappears

140 views Asked by At

I implemented pull to refresh functionality for my controller:

- viewDidLoad {
self.refresh = [[UIRefreshControl alloc] init];
[self.refresh addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:self.refresh];
}

- (void) refreshData {
__weak myController *weakSelf = self;
[[NetworkcallManager instance] getCall:^(NSString *result){
    if(weakSelf != nil) {
                [weakSelf.refresh endRefreshing];
                [weakSelf.tableView reloadData];
            }
    }];
}

The refresh works as expected, but when I pull down the screen too hard then the entire screen disappears for a moment and then the data gets refreshed.

Is there a way to avoid disappearance of the screen? I am wondering if it is because of reloadData function. In case it calls 'viewWillAppear' then I can understand the problem I am facing. (My viewWillAppear code results in momentarily blank screen).

Edit: If I pull down without internet connection (turned off the wifi) then the screen doesn't disappear.

1

There are 1 answers

0
A_G On BEST ANSWER

I got the issue. In the code I am purging the table and then updating it. As a result, the screen disappears momentarily.