Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bug with scrollsToTop and UIRefreshControl

I have a bug in my iOS App. I'm using a UITableView, in which I implemented a "pull to refresh" controller like this :

self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.backgroundColor = [UIColor clearColor];
self.refreshControl.tintColor = [UIColor blackColor];
[self.refreshControl addTarget:self
                            action:@selector(loadTheXML)
                  forControlEvents:UIControlEventValueChanged];

But, I have a little bug. If I scroll down the table, and if I tap the status bar to scroll to the top of the table, the refresh controller is partially displayed. Here a gif of what is happening : gif link.

If I use this refresh controller one time, the bug is not happening anymore, when I tap the status bar, it scrolls to the top of table.

Any idea on how to fix this bug ?

like image 970
ThibaultV Avatar asked Nov 20 '14 02:11

ThibaultV


1 Answers

I am experiencing the same bug, and it only happens when you have an attributed title. It also happens, if I first time tap a search bar, the result is the same. Here is a workaround that worked for me:

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
{
     if(self.refreshControl!=nil)
     {
          [self.refreshControl beginRefreshing];
          [self.refreshControl endRefreshing];
     }
     return scrollView.scrollsToTop;
}
like image 97
AlexeyIS Avatar answered Nov 07 '22 08:11

AlexeyIS