Prefer Large Titles and RefreshControl not working well
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)
UIRefreshControl renders behind UINavigation w/ Large Titles
It looks like you are setting the refresh control after the large navigation has been configured.
Try changing the order to something like this -
override func viewDidLoad() {
super.viewDidLoad()
load()
configureTableView()
configureUI()
}
.......
func configureTableView() {
tableView.backgroundColor = .usingHex("fafafa")
tableView.tableFooterView = .init()
tableView.contentInsetAdjustmentBehavior = .always
tableView.refreshControl = .init()
}
func configureUI() {
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.title = "Latest content"
}
iOS 11 scroll to top when using large titles doesn't work properly
Okay so I found why the problem occurs, but not how to fix it in that exact scenario.
If you're using large titles and a UITableViewController with the navigation bar translucency set to off the problem will occur.
When you turn translucent back on the problem goes away.
If you're using a TableView in a normal UIViewController the problem always occurs.
Edit
Turns out setting "extendedLayoutIncludesOpaqueBars = true" fixes the problem if you're using a translucent navigation bar!
Similar question: UIRefreshControl() in iOS 11 Glitchy effect
UIRefreshControl endRefresh jumps when used with Large Title enabled
The problem is related to layout.estimatedItemSize = CGSize(width: 20, height: 20)
When we use AutoLayout
to resize the cell, it creates a bug with UIRefreshControl
and navigation bar large title. So, if you use layout.estimatedItemSize
with an equal or greater size than we expected. So the bug will not happen and the glitch will not happen.
Basically, the problem is when we call updateData
but the cell is bigger than we expect and each cell of the UICollectinView
will resize to a bigger size then the UICollectionViewController
will glitches.
How to add refresh control to collection view large titles navigation bar in iOS 11?
As of iOS 10, UITableView
and UICollectionView
has refreshControl
property.
So, instead of:
tableView.addSubview(refreshControl)
you do:
tableView.refreshControl = refreshControl
and this should work for new big headers in iOS 11.
UIRefreshControl in a UIScrollView is not triggered when Large title is used
I had the same problem a while ago and for me I could make it work by calling scrollView.refreshControl.didMoveToSuperview()
in viewDidAppear
.
Related Topics
Why Can't You Assign an Optional to a Variable of Type 'Any' Without a Warning
Reading Currently Playing Track in MACos Using Scriptingbridge Not Working
Make a Uibarbuttonitem Disappear Using Swift iOS
How to Create a String from Utf8 in Swift
Rxswift Merge Different Kind of Observables
Implementing a Function with a Default Parameter Defined in a Protocol
Sprite Kit Physicsbody.Resting Behavior
How to Detect Absent Network Connection When Setting Firestore Document
Higher Order Function: "Cannot Invoke 'Map' with an Argument List of Type '((_) -> _)'"
Why Unsaferawpointer Shows Different Result When Function Signatures Differs in Swift
How to Bind Different Associated Values in a Swift Enum to the Same Var
"Generic Parameter Could Not Be Inferred" in Swiftui Uiviewrepresentable
How to Test Whether Generic Variable Is of Type Anyobject
Extending Collection with a Recursive Property/Method That Depends on the Element Type
Swiftui - Wait Until Firestore Getdocuments() Is Finished Before Moving On
How to Tell If a Node Is on the Screen Spritekit Swift
Swiftier Swift for 'Add to Array, or Create If Not There...'