Sticky UINavigationbar after RefreshControl refreshed since iOS 11
Asked Answered
B

5

6

navbar stays big

We have a modulised App using two Navigation-hierarchies, therefore the two stacked Navbars… Sometimes, when pulling the refreshcontrol the navbar stays big and does not drop back to the normal size after finishing the refresh. I can only guess, in which case it drops back and in which it doesnt… Visual debugger shows, that the view using this space is a _UINavigationBarLargeTitleView. In viewDidLoad, the self.navigationController.navigationBar.prefersLargeTitles is set to NO.

enter image description here

RefreshControl is added in viewDidLoad via:

self.refreshControl = [RefreshControl new];

Some things i already tried:

  • setting the tableViews contentOffset to (0,-1).
  • set prefersLargeTitles to YES, then to NO.
  • set the UINavigationControllers self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
    • logging the different states of the UIRefreshControl: sticky view and working view produces the same logging.

Does anyone have an idea what could cause this problem? As i said, i am not even sure when exactly this happens and when not…

Bogart answered 29/11, 2017 at 13:16 Comment(0)
P
5

It seems that this issue only happens when navigationBar.isTranslucent == false. I needed this setting to get a real 100% black navigation bar.

For the time being I use this extremely dirty hack, inspired by the answer of Exception:

self.refreshControl?.endRefreshing()
if #available(iOS 11.0, *) {
    self.navigationController?.navigationBar.isTranslucent = true
    self.navigationController?.navigationBar.isTranslucent = false
}
Pocketbook answered 9/1, 2018 at 20:14 Comment(0)
P
1

Definitely a bug from Apple. Could not make it work except for the workaround below.

tableView.reloadData {
    // Slightly scroll up, moving the navigation bar back to place
    self.tableView.setContentOffset(CGPoint(x: 0, y: -0.3), animated: false)
}

NOTE: Must be after the tableView has reloaded and with no animation.

Pulling answered 11/4, 2018 at 11:54 Comment(0)
A
0

It looks like it's a bug from Apple. Try this

tableView.refreshControl?.endRefreshing() //Because of a bug in iOS11 that leaves empty placeholder for refresh control navigationController?.navigationBar.setNeedsLayout() navigationController?.navigationBar.layoutIfNeeded()

also try

navigationController?.navigationBar.appearance().isTranslucent = true

Averroes answered 27/12, 2017 at 9:24 Comment(0)
H
0

Also, if you have deformed title or first cell you can add this line:

tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)

It should help to return title or cell in the normal state. Fully code may be looking like this:

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
   self.navigationController?.navigationBar.isTranslucent = true
   if self.refreshControl!.isRefreshing {
       self.refreshControl!.endRefreshing()
   }
   self.navigationController?.navigationBar.isTranslucent = false
   self.tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
}
Hearsay answered 9/10, 2018 at 8:52 Comment(0)
B
0

In my case the cause was the setting nil to my tableView.tableFooterView with tableView.reloadData(). So I just started hiding tableView.tableFooterView instead of setting nil to that view and my glitch gone

Birdsong answered 20/10, 2023 at 11:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.