Giter VIP home page Giter VIP logo

tlyshynavbar's Introduction

TLYShyNavBar banner
v1.0, Finally! With better code design, and fully featured!

Pod Version Pod License Carthage compatible

This component helps you mimic the navigation bar auto scrolling that you see in the Facebook, Instagram, 9gag (which uses this!) and other apps. Not only that, but with the ability to add an additional extension that scrolls along as well! It is designed for ease of use, and is battle tested in our own Telly app[1]!

Battle Tested!!

[1]: AppStore version doesn't have the latest, though. Coming soon. 😁
[*]: Content are shown for demo purpose only of how this component is used in the Telly app. We hold the right to show those contents as part of our contract with Sony Pictures.

Outline

Features

Feature Demo
Scroll a UINavigationBar with an extension view
Support opaque and translucent UINavigationBars
Fully featured, with animations and variable resistance
Responsive, resilient and robust
Supports UITableView, with headers, too!
UICollectionView is more than welcome
In-call status bar? No problem!
Sticky extension view (Thanks @yukaliao !)
Sticky navigation bar (Thanks @TiagoVeloso!)
Fade the entire navbar (Thanks @longsview!)

You can test some of these features in the Objective-C demo:

Quick Start

  1. Get the component
  • Using CocoaPods:
    Add the following to you Podfile pod 'TLYShyNavBar'
    Import the header #import <TLYShyNavBar/TLYShyNavBarManager.h>

  • Using Carthage (Thanks @bradleyayers!):
    Add the following to your Cartfile github "telly/TLYShyNavBar"
    Import the header #import <TLYShyNavBar/TLYShyNavBar.h>

  • Using Submodules:
    Download the project/git submodules, and drag the TLYShyNavBar folder to your project.
    Import the header #import "TLYShyNavBarManager.h"

  1. Write one line of code to get started!!
/* In your UIViewController viewDidLoad or after creating the scroll view. */
self.shyNavBarManager.scrollView = self.scrollView;

IMPORTANT NOTES!!

  1. Don't use with UITableViewController. Add a UITableView as a subview of UIViewController instead.
  2. If you are assigning a delegate to your scrollView, do that before assigning the scrollView to the TLYShyNavBarManager! To learn more, see below.

Using TLYShyNavBar in Swift

Nothing special is needed, really. Just make sure you have a Bridging Header setup, and import:

#import "TLYShyNavBarManager.h"

Then, you should be able to follow the Objective-C instructions, since the code is almost identical.

Design Goals

  • Ease of Use: This is the most important, and should never be compromised. Even if compatability breaks or versatility is limited, the component should remain easy to integrate.
  • Portable: Less dependencies, lightweight, self-contained, ... etc.
  • Compatability: Whenever possible, the component should simply work with whatever you throw at it.

A Deeper Look

The above example, while small, is complete! It makes the navigation bar enriched with humility, that it will start getting out of the way when the scroll view starts scrolling. But, you may want to do more than that!

ACCESS THE MANAGER OF SHYNESS

Simply access it within your UIViewController subclass as a property. The property is lazy loaded for you, so you don't have to instantiate anything:

self.shyNavBarManager

ADDING AN EXTENSION VIEW

You can assign your own extension view, and it will appear right beneath the navigation bar. It will slide beneath the navigation bar, before the navigation bar starts shrinking (contracting). Adding an extension view is as simple as:

/* Also in your UIViewController subclass */
[self.shyNavBarManager setExtensionView:self.toolbar];

To stick the extension view to the top and have it remain visible when the navigation bar has been hidden:

/* Also in your UIViewController subclass */
[self.shyNavBarManager setStickyExtensionView:YES];

CONTROLLING THE RESISTANCE

When you starting scrolling up (going down the view) or scrolling down (going up the view), you may want the navigation bar to hold off for a certain amount (tolerance) before changing states. (i.e. if the user scrolls down 10 px, don't immediately start showing the contracted navigation bar, but wait till he scrolls, say, 100 px).

You can control that using the following properties on the shyNavBarManager:

/* Control the resistance when scrolling up/down before the navbar 
 * expands/contracts again.
 */
@property (nonatomic) CGFloat expansionResistance;      // default 200
@property (nonatomic) CGFloat contractionResistance;    // default 0

CONTROLLING THE FADE BEHAVIOR

You can customize the fade behavior of the UINavigationBar through this property:

/* Choose how the navbar fades as it contracts/expands.
 * Defaults to FadeSubviews
 */
@property (nonatomic) TLYShyNavBarFade fadeBehavior;

How it Works

OK, I'll admit that I added this section purely to rant about how this project came together, and the decision making process behind it.

THE BASICS

At a component-user level, this works by adding a category to UIViewController with a TLYShyNavBarManager property. The property is lazily loaded, to cut any unnecessary overhead, and lower the barrier of entry. From the property, you can start customizing the TLYShyNavBarManager for that view controller.

Now, you may start asking, what about the navigation bar? Well, the navigation bar is accessed from the view controller your using the manager in. Let's break that down...

  1. When you access the shyNavBarManager for the first time, it is created with the self parameter passed to it, effectively binding the shyNavBarManager to the UIViewController.
  2. The shyNavBarManager accesses the UINavigationBar through the assigned UIViewController.

... And that is how the basic setup is done!

THE EXTENSION VIEW

When you call setExtensionView:, it simply resizes an internal container view, and adds your extension view to it. There is no magic here, just simple, single view extension.

CAPTURING SCROLL VIEW EVENTS

This one was a pain... First, the experiments that this project went through included:

  • Observing the contentOffset property
  • Adding self as a UIGestureRecognizer target
  • Adding a UIPanGestureRecognizer to the scroll view.
  • Make the user implement UIScrollViewDelegate, and send us the events.

The above didn't yield the perfect experience we were hoping for, except the last one. It did, however, make for redundant code everywhere, and forced the component user to implement the UIScrollViewDelegate. That's when the NSProxy happened.

When you assign the scrollView property to the TLYShyNavBarManager, we attach a proxy object to the UIScrollView as the delegate, and then the original delegate to that proxy. The proxy forwards the events we are interested in to the TLYShyNavBarManager, and of course, does everything else normally for the original selector, you won't even notice a thing!

THE DRAWER CONCEPT

The way the offsets are applied to the navigation bar and extension view is through an elegant doubly linked list implementation. We set the offset to the first node (navigation bar), and ...

  • If it is contracting:

    • We pass the contraction amount to the next node, and it returns a residual amount.
  • If we are expanding:

    • We process the offset in the first node, and pass the residual to the next node.

It is a simple concept. Say we dragged down by 100 px while the navbar was contracted. The navigation bar would take 44 px of that to expand, and then pass the residual 56 px to the next node (extension view) to calculate its offset. The same goes for contracting, but it starts from the last node, all the way up to the navigation bar.

We also add a parent relationship for a single purpose: Make the child follow its parent's offset. So, if the parent (e.g. navigation bar) is scrolling away to the top, we make sure the child accommodates the parent's offset in the calculation, so it appears as if the child is a subview of the parent.

Note: Even though there might be an illusion that the views are expanding and contracting, it's really just a translation (scrolling) of the views. There might be an advantage to actually resizing the bounds, so the extension view doesn't appear behind the navigation bar, for example, so that approach might be explored in the future.

FAQ

Opaque Navbar Shows Black Bar When Scrolled Up

You have to check the «Extend Edges» Under Opaque Bars in the View Controller configuration. Credit for this solution goes to @tiois.

I get an exception saying: "Please make sure the viewController is already attached to a navigation controller"

There are downsides in making this component as easy to use as it is. If you have read the how it works section carefully, you'd realize that trying to configure the the shyNavBarManager before it is included in the UINavigationController hierarchy, will break the component, since within the component, we cannot find the navigation bar, and an assert is triggered:

NSAssert(navbar != nil, @"Please make sure the viewController is already attached to a navigation controller.");

Of course, that can be avoided by creating your own TLYShyNavBarManager, like so:

TLYShyNavBarManager *shyManager = [TLYShyNavBarManager new];
shyManager.expansionResistance = 777.f;

/* ... sometime after the view controller is added to the hierarchy  */
viewController.shyNavBarManager = shyManager;

Contributing

PRs are welcome! It is important to test changes, though. Simply go over the demo, make sure nothing is broken. Please do check both translucent and opaque modes. Once all is good, you're good to go!

If it is a feature or bug, it would be greatly appreciated if a new view is added to the demo project demonstrating the bug/feature.

Thanks for everyone who opened an issue, shot me an email, and submitted a PR. Special thanks to those who submitted code that got checked in! This project was made possible with your help. (See contributors graph)

Author

Mazyod (@Mazyod)

Similar Projects

tlyshynavbar's People

Contributors

aasatt avatar akshya672222 avatar alegch avatar anovoselskyi avatar blackm00n avatar bradleyayers avatar dagagren avatar evands avatar gfzabarino avatar isevendays avatar koenbud avatar longsview avatar maryom avatar mazyod avatar modastic avatar ndrewh avatar remki avatar richarddas avatar skela avatar sonxurxo avatar yknl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tlyshynavbar's Issues

How to use library with complicated structure viewcontroller

Thanks for your wonderful library.

I'm trying to hide NavigationController with this library but it's not working. I think that causes my ViewController is a little complicated.
My viewController extend AXStretchableHeaderTabViewController library whose structure is like below.

Stretchable HeaderView
|
ParentContainerViewController
|
|-- FirstSubViewController (CollectionView)
|-- SecondSubViewController (TableView)
|-- ThirdSubViewController(TableView)

ParentContainerView extends AXStretchableHeaderTabViewController and has UIScrollView as ContainerView. I try to set it like "self.shyNavBarManager.scrollView = self.containerView;" but not working also " [self.shyNavBarManager setExtensionView:stretchableheaderView Instance];" is not working.Even when I doing that in SubViewController, it was not working.

As if it is scrolling in SubViewController, I can not get scroll delegate in ParentContainer otherwise can not get navigationController and Navbar in SubViewController.

I saw your code but it's tough to find which part is not workig for me in my poor skill.
If you have any idea, could you let me know what's wrong?

Thanks!

Black background when using Swift

 self.navigationController?.navigationBar.barTintColor = UIColor(red:241/255, green:48/255, blue:29/255, alpha:1)
        self.navigationController?.navigationBar.translucent = false

I'm setting my bartintcolor in my view controller and I got this weird black background when I scroll down.
img_1168

Views in Navbar disappear when rotating while shrunk

First time posting an issue; hope I'm not breaking an "rules"

Anyways, I'm using TLYShyNavBar with a TableView and it works great for the most part. However, the Title object in my NavBar disappears when the NavBar is "shy," as seen in this video: http://youtu.be/Eb2B4J040ak

My NavBar is Opaque, and I fixed that bug with self.extendedLayoutIncludesOpaqueBars = true — not sure if that's affecting it.

Let me know if any other info is needed. Thanks!

UITableView Header Section not scrolling properly

Hello. I use your code wonderfully.
And this time I make a app with Instagram SDK.

So make a tableView and custom Header Section.
tableView issued is solved, but problem is Header Section.
When navigationBar hidden, Header Section is not follow just remained.

like this.
2014-09-05 4 53 31

How can I make Header section could move in navigationBar.position when it disappear?

Extension View Shown, recognizes proper View Controller, No hiding behavior

Hello,

_Update, I've narrowed down the cause of the issue, please scroll to stars to see_

I have a UIViewController embedded in a navigation controller. Not sure if this is relevant, but a tabBarController is my root view controller.

Anyways I setup the shynavbarcontroller per the quick setup in viewDidLoad and set a tableView as the scrollview. This code comes after functions thats setup the tableview and add it as a subview to the view controller.

I also created an extension view similar to the example project, which shows up fine. There is no response to the tableview scrolling though. Is there a setting or code I have in place that may cause the shynavbar to not "see" movements in the tableview? The tableview behaves normally but the extension and the navbar never budge.

_UPDATE: If I remove - (void)viewWillAppear:(BOOL)animated function, the shynavbar behaves as expected. Is this a bug?_

Setup code below, I'll post any other code that would help my situation:

self.shyNavBarManager.scrollView = self.tableView;

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 44.f)];
view.backgroundColor = [UIColor redColor];
[self.shyNavBarManager setExtensionView:view];

Issue while Implementing this code with UIScrollview

Hi,

I have used your code in my application & it works pretty good. Only it shows issue while i am using the UIScrollView,

My Code structure is like below:

  1. There is one view controller which contains a scrollView. Inside that scroll view i have loaded 4 another views.
  2. The scrolling of pages are only horizontally & all the view contains a collection view.
  3. So when i scroll the collection view to up, the navigation bar is get hide as per requirement but while i scroll the UIScrollView horizontally the next view shows a white screen at a top (in place of navigation bar).

Issue when using scroll from child view controller

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!

Issue when going active from the background

Hi

I've found an issue when the apps comes alive from the background. Scenario:

  • Scroll to hide the navigation bar
  • Click the device's home button to go to the "desktop"
  • Re-open the app by tapping its icon

At first, the navigation bar remains hidden, but after half a second or so it goes back to its normal state, but the buttons, title, etc. do not appear until scrolling again.

Doesn't work with UITableViewController

Hey again! We've been messing around with this project and I seem to have found a few funny cases.

Using a barebones UITableViewController causes the component not to work. I uploaded my sample project showcasing this: http://cl.ly/3d3A3W3b3W0u

Along with the navigation bar never hiding, if you scroll to the bottom of the table and bounce, it causes the whole table to jump up a bit leaving some whitespace at the bottom.

Not a big deal but was just wondering if you were aware of this issue.

Programmatically changing content offset triggers TLYShyNavBar

I am developing a chat application where I set the content offset programmatically when inserting new rows in chat table view.

TLYShyNavBar trigger when this happens and shortly contracts the navigation bar. Is there a way to solve this?

For instance, temporarily disable ShyNavBar while programmatically changing the content offset or make it trigger only when the user is scrolling.

setExtensionView: not compatible with Autolayout

I'd love to use TLYShyNavBar, but it doesn't seem to support extension views when auto layout is enabled. TLYShyViewController.updateYOffset is using self.view.center = ... to move the view which very quickly gets overridden by the auto layout engine. Another project mentioned on your project page, https://github.com/andreamazz/AMScrollingNavbar, seems to have a solution for this using [self followScrollView:self.scrollView usingTopConstraint:self.topLayoutConstraint];. Would it be possible to add a similar solution to this project?

How to not autoshow the navigationbar when back?

In controller A, I scroll to top, the navigationbar work fine and hide, and click a push segue go to the next controller B.
When I back to pre controll A, navigationbar always auto show again.
How to dismiss it?

PushViewController with NavigationBarHidden = YES

Hi,
I have been using this library since you published, and I really like it so much!
and I am using this on my current project right now, :)

I have just small issues:

I have project that pushes to navigation on appear setNavigationBarHidden = YES

The effect is:

  • the navigationBar will be hidden on the transition effect and the extensionView will be left shown (seems not good to see)

question:

  1. Can we also set the extensionView hidden when Navigation is hidden?
  2. when pushed and the extensionView and the navigation is hidden, can we let it be hidden upon push to another viewController? because right now when I push, It automatically shows the navigation and extensionView

Sorry for noob question :)

NavigationBar is drawn on top of tableview when Keyboard appears

Im using TLYShyNavBar in UITableViewController. I have an InputAccessoryView with a UITextView inside. When UITextView is tapped, keyboard appears. This causes hidden navBar to be drawn on top of the keyaboard, incorrectly.

How can I manually show and hide the bar, so that when keyboard appears I can be able to hide the navbar.

thanks

Crash when used in UIPageViewController?

Hi
First of all great project, very elegant compared to most of the other solutions!
I've been playing with using it with UICollectionViewControllers within a UIPageViewController - when the 'page' is changed to a new UICollectionViewController, I set self.shyNavBarManager.scrollView to collectionViewController.collectionView.
It works fairly well, but randomly crashes with EXC_BAD_ACCESS on the TLYDelegateProxy property originalDelegate during what appears to be a call to respondsToSelector. originalDelegate isn't nil, and as the collectionView has no delegate set by me the originalDelegate is a TLYDelegateProxy too.

Secondly, but far less important - when 'paging' to a new UICollectionViewController and setting shyNavBarManager.scrollView, the contentOffset isn't applied to the new scrollView. I'm guessing this could be solved fairly easily - may make a pull request if you don't mind :)

Thanks for sharing your work!

[NSProxy doesNotRecognizeSelector:_accessibilityValueForKey:]

 -[NSProxy doesNotRecognizeSelector:_accessibilityValueForKey:] called!
Thread : Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x27f0a5f7 __exceptionPreprocess + 126
1  libobjc.A.dylib                0x3577cc77 objc_exception_throw + 38
2  CoreFoundation                 0x27f0a53d -[NSException initWithCoder:]
3  Foundation                     0x28c10181 -[NSProxy doesNotRecognizeSelector:] + 68
4  CoreFoundation                 0x27f0d999 ___forwarding___ + 712
5  CoreFoundation                 0x27e3eb88 _CF_forwarding_prep_0 + 24
6  UIKit                          0x2662b859 -[UIScrollViewAccessibility _axCleanupDelegateClearer] + 100
7  UIKit                          0x2662b765 -[UIScrollViewAccessibility clearDelegateClearer] + 24
8  UIKit                          0x2662ba91 -[UIScrollViewAccessibility setDelegate:] + 28
9  UIKit                          0x2b4541f7 -[UICollectionView setDelegate:] + 46
10 Design Shots                   0x00184f39 -[TLYShyNavBarManager dealloc] (TLYShyNavBarManager.m:122)

Using with UIWebView

Hello, i tried to use it with a UIWebView, but when i scoll the WebView nothing happens. Any suggestions?

Abrupt visual changes when pushing view controller

When scrolled down a list, with shy nav bar hidden, when the view controller is about to disappear (e.g. pushing another view controller because user tapped on a cell), the navigation bar abruptly (without animation) appears briefly before the view controller transition

Flickery UIRefreshControl

After adding shyNavBarManager, i.e. adding the following line:

self.shyNavBarManager.scrollView = self.tableView;

Everything works perfect, except that the UIRefreshControl is not behaving normally: It is flickery, only shows a "crosshair" while dragging down, and disappears when let go at refreshing position. See attached gif.

I have initially implemented everything with UITableViewController, hit the bug of extension view not fixed (#1), and then migrated everything to UIViewController. Therefore I can verify that this bug exists in both UIViewController and UITableViewController.

FYI, here is the code I wrote to add UIRefreshControl

UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refresh)
         forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
[self.tableView addSubview:self.refreshControl];

bug

Remove extension view

I'm assuming you can remove the extension view using:

[self.shyNavBarManager setExtensionView:nil];

But it's not working. I guess this line is missing in setExtension method:

_extensionView = view;

shybar doesn't "unhide" when the tableview height or content height shrinks

Not sure if i'm doing something wrong but easy way to reproduce:

  1. Have a tableview where the contentsize is smaller than the height.
  2. Contentsize should be large enough such that when the keyboard appears the tableview can scroll up. 3. Scroll the tableview content so that the status bar shrinks
  3. dismiss the keyboard, now the tableview will look how it did in step 1 but the status bar will still be shrunk and there will be a space between the shrunk status bar and the topmost cell.

Another way to reproduce:

  1. Have a tableview where the contentsize is larger than the tableview height.
  2. Scroll the tableview content so that the status bar shrinks
  3. Delete a tableview cell so that the contentsize is now smaller than the tableview height.
  4. same scenario as in the previous situation. status bar will still be shrunk and there will be a space between the status bar and the topmost cell.

Gonna guess the status bar height is determined by scroll events but doesn't get updated when the scrollview height changes.

Not working with my UIViewController subclass

self.shyNavBarManager.scrollView = self.tableView;
            UIView *eView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)];
[eView addSubview:self.calendarMenuView];
[eView addSubview:self.calendarContentView];
[self.shyNavBarManager setExtensionView:eView];

This is what I am working with. I have my tableview set up exactly as your scrollview in the demo. The delegate is setup in the storyboard as well. I have tried putting this in my viewDidLoad and viewDidAppear. The UITableView moves but the extension and navBar do not move at all. I am importing <TLYShyNavBar/TLYShyNavBarManager.h> in the header file so I can access the shyNavBarManager. Still nothing

Demo Broken, Code doesn't compile properly

Running the demo gives this error: "You are using the component wrong... Please see the README file."

The code, when compiled in my project, gives three errors that all relate to TLYShyNavBarManager.m, line 92: __weak typeof(self) weakSelf = self; <- the typeof needs __ in front

I still get the same error in my project even after correcting the code.

Question about slight difference in behavior

First of all, this looks awesome. I have been messing with this stuff myself and your solution looks like the best and most robust I've seen yet. Great work!

I haven't poked around the code yet but noticed a slight difference in behavior between this component and what Instagram/Facebook use. Is there any plan to add the ability to push a view onto the stack without expanding the navigation bar on the current view? Then, when popping back, popping back to the bar in the state it was in (so if it was hidden, leaving it hidden?).

To put it more simply, take a look at the Facebook app:

  • If you hide the navigation bar then push a new view, the new view has a new navigation bar that gets pushed with it, not changing the root view at all.
  • If you unhide the navigation bar and push a new view, it gets pushed like a view controller normally does and the new navigation item fades in over the old one.

I have introspected those other apps' view hierarchies using Spark Inspector on a jailbroken device in the past and as far as I remember the way Facebook accomplishes it is by having the status bar background actually being a separate view than the navigation bar itself, so it is able to stay anchored on the root view while the actual navigation bar is pushed on top of it with the next one. Instagram did the same thing but in their case it is more trivial because no matter what state it is in when you push, the pushed navigation bar is obviously a different view (not even the same color).

Anyways, the component is pretty awesome without this but it would perhaps be a little less jarring to the user if the navigation bar does not pop in as a new view is about to be pushed. I'm not sure if this can be easily added while maintaining the simplicity of the component.

App crash when swip edge to pop

Thanks for sharing this wonderful project for us,I tried today,and I found a bug.
Open app,push a view controller,scroll down to the bottom,nav bar hidden,then swip from left edge to right, so it will pop to show parent view controller,then It gets a exc_bad_access error.

Using with CollectionViewController

Hello, i tried to use it with a collectionView, but the headers appears behind the status bar when the navigationbar is hidden. Any suggestions?

iOS 8 Simulator: [NSProxy doesNotRecognizeSelector:_accessibilityValueForKey:]

In iOS 7 the library functions without a problem both on simulator and device -- however, when I switch to iOS 8 on the simulator, I get the below error. I do not receive the error on a physical iOS 8 device.

This error occurs when trying to go back from any pushed VC that has ShyNavBar enabled using
self.shyNavBarManager.scrollView = self.tableView;

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 
'*** -[NSProxy doesNotRecognizeSelector:_accessibilityValueForKey:] called!'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b0793f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010ad12bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010b07932d +[NSException raise:format:] + 205
    3   CoreFoundation                      0x000000010afd87fc ___forwarding___ + 988
    4   CoreFoundation                      0x000000010afd8398 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000011b492daf -[UIScrollViewAccessibility _axCleanupDelegateClearer] + 89
    6   UIKit                               0x000000011b492cd6 -[UIScrollViewAccessibility clearDelegateClearer] + 30
    7   UIKit                               0x000000011b492fde -[UIScrollViewAccessibility setDelegate:] + 36
    8   UIKit                               0x0000000108d44e73 -[UITableView setDelegate:] + 122
    9   MyApp                          0x0000000107018f17 -[TLYShyNavBarManager dealloc] + 215
    10  libobjc.A.dylib                     0x000000010ad2728e _ZN11objc_object17sidetable_releaseEb + 236
    11  libobjc.A.dylib                     0x000000010ad15426 _object_remove_assocations + 410
    12  libobjc.A.dylib                     0x000000010ad1f9be objc_destructInstance + 109
    13  libobjc.A.dylib                     0x000000010ad1f9e4 object_dispose + 22
    14  UIKit                               0x0000000108dd91ba -[UIResponder dealloc] + 90
    15  UIKit                               0x0000000108d86353 -[UIViewController dealloc] + 1899
    16  UIKit                               0x0000000108c5994d __destroy_helper_block_114 + 93
    17  libsystem_sim_blocks.dylib          0x000000010ba54734 _Block_release + 196
    18  UIKit                               0x0000000108cd480d -[UIViewAnimationBlockDelegate dealloc] + 63
    19  libobjc.A.dylib                     0x000000010ad2728e _ZN11objc_object17sidetable_releaseEb + 236
    20  CoreFoundation                      0x000000010af50d2b CFRelease + 603
    21  CoreFoundation                      0x000000010af8593d -[__NSDictionaryI dealloc] + 125
    22  libobjc.A.dylib                     0x000000010ad2728e _ZN11objc_object17sidetable_releaseEb + 236
    23  libobjc.A.dylib                     0x000000010ad278cd _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 591
    24  CoreFoundation                      0x000000010af70346 _CFAutoreleasePoolPop + 22
    25  CoreFoundation                      0x000000010afa4473 __CFRunLoopRun + 2051
    26  CoreFoundation                      0x000000010afa3a06 CFRunLoopRunSpecific + 470
    27  GraphicsServices                    0x000000010cb0f9f0 GSEventRunModal + 161
    28  UIKit                               0x0000000108c63550 UIApplicationMain + 1282
    29  MyApp                          0x0000000106eaae03 main + 115
    30  libdyld.dylib                       0x000000010ba09145 start + 1
    31  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Update the height of the extension view after being set

When I change the height of the extension view after calling setExtensionView, the contractionAmount and expandCenter of extensionController remain unchanged.

What should I do after updating the extension view frame height?

prepareForDisplay never called

I have been using a local fork of ShyNavBar for some time. Today I tried to use 0.9.7 and noticed that the navbar never hides. I'm probably missing something, but I need some help finding out what...

I found out that self.isViewControllerVisible is false in _shouldHandleScrolling.
This is because prepareForDisplay is never getting called because _internalShyNavBarManager returns NULL.

- (void)tly_swizzledViewWillAppear:(BOOL)animated
{
    NSLog(@"OBJECT: %@", [self _internalShyNavBarManager]);
    [[self _internalShyNavBarManager] prepareForDisplay];
    [self tly_swizzledViewWillAppear:animated];
}

Outputs OBJECT: (null)

Support for non-translucent navigation bars?

I made a simple project with a UIViewController with a UITableView inside it. By default, it all works fine. Changing the translucent property of the navigation bar to NO however causes some issues. It seems the reason is this component depends on a translucent bar as it only adjusts the content inset of the scroll view (and a scrollview with a non translucent bar doesn't use this functionality since there is no hidden portion). When the navigation bar hides, it leaves a blank space in its place since the underlying view does not actually extend underneath it.

Sample project here: http://cl.ly/2D2F090o2I3d

Wondering if there is a straightforward way to solve this.

The way I have solved it in my app for the short term is as follows:

  1. manually extend the frame of the scroll view underneath the nav bar (so decreasing origin.y and increasing size.height both by the height of the navigation bar)
  2. overriding topLayoutGuide to return a custom object with length being the height of the navigation bar so TLYShyNavBar can use that value as if the navigation bar is transparent without knowing or caring that it isn't.

This solution is working for me at the moment and behaves smoothly but has a few issues. First off, I don't see a way of easily extending this functionality into the component. The second is that overriding the layout guide seems to actually be unsupported behavior and although it is working for me, can cause some issues with autolayout, as shown here.

What do you think?

Improved support for swapping scroll views.

Use Case:
My Extension view contains a toggle that I use to switch between two content scroll views. Both scroll views should appear just below my extension view, however when I toggle between them (and assign the newly visible scroll view to the shy nav bar), the content insets of the new scroll view are not updated according to the height of the extension view.

In an attempt to fix this I have exposed the layoutViews method in my client code, so that I can invoke it when I swap the scrollViews, however the content inset of the new scroll view is not set because UIEdgeInsetsEqualToEdgeInsets(scrollInsets, self.previousScrollInsets) causes the method to return. Setting previousScrollInsets to UIEdgeInsetsZero prior to this seems to do it, however it feels like a hacky solution so would like to raise this so that a proper fix can be devised.

Not working properly while turn on hotspot

As we make a hotspot connecting, a blue toolbar, which height is 20, will appear on the top of screen. I found 2 problems with this situation.

1.TLYShyNavBar's height become larger.
2.The connected scrollview and extensionview can't be adaptive.

Issue with plain table view with sections and search bar in header

Hello, I am using component on view with tableview witch have refresh control, searchbar in header, sections and index bar.
The issue is that table header goes under white gap when nav bar scrolls up, the sections issue that they stop under standart navigation bar place.
Wich solution can I use here?

Thank you!

Instructions to get it working in UITableViewController

Hi!
Thanks for this control, truly great work!
In my case, the screenshot you see below is from a UITableViewController. The position of the drawer is wrong and i can not scroll the whole table. I made an experiment and used a UIVIewController and everything worked smoothly.
Is anything special i can do to get it working with a UITableViewController?
ios simulator screen shot jul 12 2014 20 00 46

Support custom property transitions on header

There should be a public way to control the effects applied to the navbar as it disappears. At the very least, a way to disable/enable the alpha fade. (This is particularly important in cases where the navbar is a custom view)

Double Status Bar Support

When in-call or tethering, the margins aren't quite correct for both shyNavBar states. For my UITableView-embedded UIViewControllers the hidden state remains 20px, and isn't pushed behind the 40px status bar. In addition, after revealing the shyNavBar, the navigation bar grows to 62px (the 20px appendage on the double status bar remains below it). When the content in my scroll view is not pushaway-scrollable (smaller than the frame), the small contraction when bouncing it offsets the navigation bar behind the status bar, as well.

I'm not certain if every one of these issues is completely attributable to TLYShyNavBar, but I'm certain at least the first and mutations of the rest are likely to exist in other apps. If these results are intentional, please let me know if there's something else I should do with the view controller to make the presentation less intrusive.

Preserve previous state

This issue was discussed a bit here #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.

Toggling the nav bar from being "shy" or not

Hello,

Thank you so much for creating this component. The "shy" nav bar has become a very common UX practice and it's incredibly helpful to have component like this that just works out of the box.

I have a table view which is using the shy nav bar. When there are "new items" available, a red alert label is shown in the nav bar to take them up to the top and see the new items. This works great if the user actually sees the button, but if they are scrolling down they may not. What I'd like to be able to do is force the nav bar to stay visible (ie, not contract on scroll) when new items are present, and be "shy" and work as normal otherwise.

I've looked through the source and I can't seem to find any methods to toggle this behavior. Am I just missing it? If not, would this be something you'd consider adding?

Thanks!

  • Leland

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.