5
votes

enter image description hereMy 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];
}
1
What is the desired behaviour? Will it stuck there and never disappear? - gabbler
Usual behavior is tableview(dataTable) goes back up, to the same position and the refreshView goes away. This is also the desired behavior. - user1324887
So it stuck there and never goes away? - gabbler
Initially it works fine, But after I go to tab 2 and refresh data there and come back to tab1 and refresh data, Tab 1 is stuck at a position, its not going all the way back up to top. I can pull it down again, but It does not refreshes data and is stuck at that position with UIRefreshControl visible in the background, I have added a picture of the stuck area - user1324887
Not sure what is the problem is. When it is stuck, does reloadData get called? - gabbler

1 Answers

0
votes

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.