andreamazz / AMScrollingNavbar

Scrollable UINavigationBar that follows the scrolling of a UIScrollView
MIT License
6.05k stars 634 forks source link

Scroll to top doesn't work correctly in case of navigationBar without searchController #363

Closed arashetm closed 4 years ago

arashetm commented 5 years ago

Describe the bug When 'searchController' is off tapping on the collapsed navigationBar doesn't scroll to top correctly.

To Reproduce Steps to reproduce the behavior:

  1. try to comment navigationItem.searchController = UISearchController(searchResultsController: nil) in 'TableViewController'
  2. Observe error

Expected behavior Scroll to top correctly.

Screenshots image

arashetm commented 5 years ago

@andreamazz could you help me please

andreamazz commented 5 years ago

Hey @arashetm it's an issue that came up wth iOS12 IIRC, for the moment I can only offer a dirty fix:

  open func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
    if let navigationController = self.navigationController as? ScrollingNavigationController {
      navigationController.showNavbar(animated: true)
      navigationController.scrollView()?.setContentOffset(CGPoint(x: 0, y: -200), animated: true)
    }
    return false
  }

I'e put an hardcoded -200 there since I cant find the proper amount (the full navbar height i snot enough for some reason).

arashetm commented 5 years ago

@andreamazz I've tried this but does not work, the problem still remains.

alexookah commented 4 years ago

@andreamazz this should be closed as well