UIRefreshControl stuck after switching tabs in UITabBarController with UIViewControler and UITableView

enter image description here My UIRefreshControl gets stuck after switching tabs. This only happens on the first tab. Inside the TabBar, I have 2 tabs with a UIViewControler, inside which I have a UITableView.

I tried all the proposed solutions HERE and no one worked for me.

Below I do.

 - (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]; } 
+5
source share
1 answer

Since this issue has been considered hundreds of times. Adding my solution here may help someone else.

In my case, this was due to refreshControl . you need to allocate refreshControl for both views. I ended up creating refreshControlFirstView and refreshControlSecondView and solved the problems.

0
source

Source: https://habr.com/ru/post/1215373/


All Articles