Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIRefreshControl bug when entering foreground

I've noticed a little bug (but really annoying) when I use UIRefreshControl in my View Controller. When the application returns from the background the UIRefreshControl is already loaded and it looks like this:

As you can see I use a custom navigation controller which hides like in the Facebook app (AMScrollingNavBar). When I reload data in UITableView everything comes back to normal and this bug shows only after returning from the background.

This is the code which I use to initialize UIRefreshControl in viewDidLoad:

// Initializing generic refresh control
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(collectData) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:self.refreshControl];
like image 812
cojoj Avatar asked Mar 08 '14 18:03

cojoj


1 Answers

This is a known bug in iOS7. You can see it reproduce in Apple's mail app. I can confirm it has not been fixed as of iOS7.1 beta 5 iOS8.0 beta 3 iOS 10.0.1.

First, open a bug report at https://bugreport.apple.com/ My radar number is rdar://14586451, which is a duplicate of rdar://14493713 (still open).

A proposed fix is to register for UIApplicationWillEnterForegroundNotification notifications in your view controller and call [self.refreshControl.superview sendSubviewToBack:self.refreshControl]; to somewhat remedy the issue by having the refresh control appear behind your table content.

I see in the second screenshot that the refresh control shows under your cell. This is likely because you have set a clear color as your cell's background. Set it to white.

like image 134
Léo Natan Avatar answered Oct 01 '22 02:10

Léo Natan