Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prefer Large Titles and RefreshControl not working well

I am using this tutorial to implement a pull-to-refresh behavior with the RefreshControl. I am using a Navigation Bar. When using normal titles everything works good. But, when using "Prefer big titles" it doesn't work correctly as you can see in the following videos. Anyone knows why? The only change between videos is the storyboard check on "Prefer Large Titles".

With "Prefer big titles" With normal title

like image 972
Damia Fuentes Avatar asked Jun 05 '18 20:06

Damia Fuentes


4 Answers

I'm having the same problem, and none of the other answers worked for me.

I realised that changing the table view top constraint from the safe area to the superview fixed that strange spinning bug.

Also, make sure the constant value for this constraint is 0 🤯.

if using storyboard

like image 87
Bruno Cunha Avatar answered Nov 09 '22 13:11

Bruno Cunha


At the end what worked for me was:

  • In order to fix the RefreshControl progress bar disappearing bug with large titles:

    self.extendedLayoutIncludesOpaqueBars = true
    
  • In order to fix the list offset after refreshcontrol.endRefreshing():

    let top = self.tableView.adjustedContentInset.top
    let y = self.refreshControl!.frame.maxY + top
    self.tableView.setContentOffset(CGPoint(x: 0, y: -y), animated:true)
    
like image 41
Damia Fuentes Avatar answered Nov 09 '22 11:11

Damia Fuentes


If you were using tableView.tableHeaderView = refreshControl or tableView.addSubView(refreshControl) you should try using tableView.refreshControl = refreshControl

like image 7
atish vishwakarma Avatar answered Nov 09 '22 11:11

atish vishwakarma


It seems there are a lot of different causes that could make this happen, for me I had a TableView embedded within a ViewController. I set the top layout guide of the tableview to the superview with 0. After all of that still nothing until I wrapped my RefreshControl end editing in a delayed block:

DispatchQueue.main.async {
   if self.refreshControl.isRefreshing {
       DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
            self.refreshControl.endRefreshing()
       })
   }
}
like image 4
Luke Pearce Avatar answered Nov 09 '22 13:11

Luke Pearce