Prefer Large Titles and RefreshControl not working

2020-06-01 06:45发布

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

9条回答
一纸荒年 Trace。
2楼-- · 2020-06-01 07:13

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

查看更多
smile是对你的礼貌
3楼-- · 2020-06-01 07:13

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()
       })
   }
}
查看更多
smile是对你的礼貌
4楼-- · 2020-06-01 07:13

The only solution that worked for me using XIBs was Bruno's one: https://stackoverflow.com/a/54629641/2178888

However I did not want to use a XIB. I struggled a lot trying to make this work by code using AutoLayout.

I finally found a solution that works:

    override func loadView() {
        super.loadView()
        let tableView = UITableView()
        //configure tableView
        self.view = tableView
    }
查看更多
登录 后发表回答