5

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];
}
Community
  • 1
  • 1
user1324887
  • 632
  • 3
  • 11
  • 32
  • What is the desired behaviour? Will it stuck there and never disappear? – gabbler Mar 15 '15 at 04:05
  • Usual behavior is `tableview`(dataTable) goes back up, to the same position and the `refreshView` goes away. This is also the desired behavior. – user1324887 Mar 15 '15 at 06:07
  • So it stuck there and never goes away? – gabbler Mar 15 '15 at 08:41
  • 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 Mar 15 '15 at 10:54
  • Not sure what is the problem is. When it is stuck, does `reloadData` get called? – gabbler Mar 15 '15 at 11:01
  • `reloadData` is not being called after its stuck. Though `cellForRowAtIndexPath` is being called every time, If that helps. – user1324887 Mar 16 '15 at 00:51
  • I have fixed this issue. In case someone is still stuck tet me know and I can share what worked for me. – user1324887 Aug 24 '15 at 08:40
  • @user1324887 I have something similar. If UIRefreshControl is animating during a transition to another screen, it's stuck when you return. Do you know how to solve this? – Artem Stepanenko Dec 22 '15 at 20:39
  • @ArtemStepanenko 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. – user1324887 Apr 15 '16 at 04:00

1 Answers1

0

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.

user1324887
  • 632
  • 3
  • 11
  • 32