Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sticky UINavigationbar after RefreshControl refreshed since iOS 11

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…

like image 475
Tobias Avatar asked Nov 29 '17 13:11

Tobias


2 Answers

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
}
like image 98
Ely Avatar answered Oct 22 '22 14:10

Ely


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.

like image 1
Arthur Alves Avatar answered Oct 22 '22 16:10

Arthur Alves