telly / TLYShyNavBar

Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
MIT License
3.73k stars 426 forks source link

Issue when using scroll from child view controller #16

Open dron4eeek opened 10 years ago

dron4eeek commented 10 years ago

It is really cool component, great gob. I am using it on view controller which is using two collection views in scroll view added like a child view controllers, they are changing by swiping left or right. I set up everything like after scroll page changed i am seting shymanagers scroll and controller :

self.shyNavBarManager.scrollView = self.collectionViewFromChild;
[self.shyNavBarManager setViewController:rightCollectionViewController];

the same for right.

its working fine on scrolling up, navigation bar hides cool.

The problem is that when I am scrolling down and scroll offset goes under status bar a bit and i begin to scroll down navigation bar begin to appear, but it should appear only when offset y reached the status bar height. Than in expands with out animation. Video: https://www.dropbox.com/s/x024oe0hkydlfyx/bug.mp4 Please help me with this problem. How I can fix it?

Thank you!

Mazyod commented 10 years ago

Thanks for reporting the issue!

So, as far as I can tell, there are two issues here:

  1. The navbar "sticks" to the collection view when you scroll up a bit, then scroll down. It should not stick, and wait till the collection view's bounds origin aligns with the contracted navbar.
  2. The navbar is acting weird in some cases where it should animate, but it isn't. Instead, it shrinks and expand without animation.

So, regarding 1, did you change the expansionResistance to 0? That might be an issue if you did, otherwise, I am actually able to reproduce the issue, so it is valid.

Regarding 2, I'll take a look.

dron4eeek commented 10 years ago

Yes, i am changing expansionResistance after changing collections (after swiping) like this


- (void)updateScrollViewCollectionsWithType:(enum State)state
{
  [self.shyNavBarManager prepareForDisplay];
  if (state == State1)
  {
    self.shyNavBarManager.extensionView = self.searchBar;
    self.collectionViewFromChild = leftCollectionViewController.collectionView;
    [self.scrollView setContentOffset:CGPointZero animated:YES];
    self.shyNavBarManager.scrollView = self.collectionViewFromChild;
    [self.shyNavBarManager setViewController:leftCollectionViewController];
    self.shyNavBarManager.contractionResistance = 0;
    self.shyNavBarManager.expansionResistance = 200;
    [rightCollectionViewController.collectionView setContentOffset:CGPointMake(0, valueForScrollUP) animated:NO];
    [leftCollectionViewController pullToRefresh];
  }
  else
  {
    self.collectionViewFromChild = rightCollectionViewController.collectionView;
    [self.scrollView setContentOffset:CGPointMake(self.leftCollectionView.frame.size.width, 0) animated:YES];
    self.shyNavBarManager.scrollView = self.collectionViewFromChild;
    [self.shyNavBarManager setViewController:rightCollectionViewController];
    self.shyNavBarManager.contractionResistance = -self.searchBar.height;
    self.shyNavBarManager.expansionResistance = 200 -self.searchBar.height;
    [leftCollectionViewController.collectionView setContentOffset:CGPointMake(0, valueForScrollUP) animated:NO];
  }
}

Thanks for reply!

dron4eeek commented 10 years ago

I am changing it because on one collectionview I need extensionView on other i dont need it, so second collection y is up to hide extensionView.

dron4eeek commented 10 years ago

I have found some dirty solution by adding childviewcontroller to navigation controller with hidden nav bar and then setting parentviewcontroller like shynavbarmanager and its work)

Mazyod commented 10 years ago

@dron4eeek You may want to reevaluate setting the resistance to a negative value, I believe this would result in undefined behavior.

I'm glad you found a workaround! I am, however, still investigating the issue to see what could go wrong.

av0c0der commented 9 years ago

Thank you for this work! Can I bind status bar with shyNavBarManager for hiding status bar when navigation bar hides?

vishaltelangre commented 9 years ago

@Mazyod Any update on @Jauzee's question above?