My
UIRefreshControl
is stuck after switching tabs, It happenes only on the first tab. Inside TabBar I have 2 tabs with UIViewControler inside which I have UITableView.
I have tried all solutions suggested HERE and none worked for me.
Below is what I am am doing.
- (void)viewDidLoad {
[super viewDidLoad];
data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getData]];
[self addNavBar];
[self addDataTable];
//for refreshing the table data
UITableViewController *tableViewController = [[UITableViewController alloc] init];
tableViewController.tableView = dataTable;
refreshControl = [[UIRefreshControl alloc] init];
refreshControl.backgroundColor = [UIColor purpleColor];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self
action:@selector(refresh)
forControlEvents:UIControlEventValueChanged];
[dataTable addSubview:refreshControl];
tableViewController.refreshControl = refreshControl;
}
- (void)refresh {
[self loadSentData];
data = [[NSMutableArray alloc] initWithArray:[[DataCache sharedCache] getSentData]];
[self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
}
- (void)reloadData{
[dataTable reloadData];
[refreshControl endRefreshing];
}
Since this question has been viewed hundreds of time. Adding my solution here might help someone else.
In my case, it was due to refreshControl
. you need separate refreshControl
for both the views. I ended up creating refreshControlFirstView
and refreshControlSecondView
and that resolved the issues.