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

Preserve previous state #8

Open Mazyod opened 10 years ago

Mazyod commented 10 years ago

This issue was discussed a bit here https://github.com/telly/TLYShyNavBar/issues/2, but I wanted to dedicate that issue for the navbar animation.

Currently, the TLYNavBarManager applies a "cleanup" in viewWillAppear, viewWillDisappear, causing the navbar state to be lost. We can't just remove that code, but I suppose we can change the prepareForDisplay to:

(self.previousContractionState ? [self contract] : [self expand]);

and of course, remove the code that resets the previousContractionState variable.

I will probably also add a public variable that users can use to switch this behavior on and off. As far as I can tell, the facebook app, for example, doesn't preserve the states when switching tabs or pushing view controllers.

mitchtreece commented 8 years ago

Great little library :+1:

Trying to get state preservation working. I added the check into the prepareForDisplay method, but still am not able to get this working. Could you point me in the right direction?

Mazyod commented 8 years ago

@mitchtreece Thanks, appreciate you looking into this.

There is a lot of thought to be put into this, since of course, the navigation bar is still the same bar when you push a new controller. Meaning, you must somehow keep the navigation bar hidden on the current controller, while allowing the pushed controller to show its navigation bar. The same should happen when coming back.

This would be tricky, and as explained in #2, the only way could be by manipulating the visibility of the navigation bar through the navigation controller.