telly / TLYShyNavBar

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

Extensionview "vibrates", doesn't retract, on CollectionView with 0.10.0 #93

Closed dbleicher closed 9 years ago

dbleicher commented 9 years ago

My project is using TLYShyNavBar on multiple ViewControllers, mostly collectionview vc's, but also a uiwebview vc. Using an extensionview (inflated from custom view) in all cases. Through version 0.9.15, all is good. Upgraded project to the 0.10.0 release yesterday, and the extensionviews for the collectionview controllers (webview controller EV still works fine) now appears to "vibrate" during scroll down (collectionview content moves upward). It seems as if the EV is attempting to retract and expand (simultaneously) as each CV cell passes under it. It's kind of a cool visual, but not intended. Attaching the shynavbar and EV in viewDidLoad with the following:

self.extendedLayoutIncludesOpaqueBars = YES;
self.shyNavBarManager.scrollView = self.collectionView;
self.shyNavBarManager.expansionResistance = 0;
self.shyNavBarManager.contractionResistance = 0;

self.qrBar = [[MessageListQRBar alloc] initWithFrame:
              CGRectMake(0,
                         0,
                         self.view.bounds.size.width,
                         50)];

[self.shyNavBarManager setExtensionView:self.qrBar]; 

And re-setting the EV frame size on each viewWillLayoutSubviews. Have tried changing expansion/contraction values, and disabling viewWillLayoutSubviews entirely, with no effect. Issue does not appear on the webview VC (only in VCs for collectionviews), and issue goes away if I downgrade to 0.9.15. Any idea what I'm doing wrong?

phillip-martin commented 9 years ago

+1 I have witnessed similar behavior with a UITableView. Downgrading to 0.9.15 also makes the issue go away in my case.

Mazyod commented 9 years ago

hmm.. Strange, thanks for reporting this guys. I thought the 0.10.0 changes were strictly an improved subset of the 0.9.15 implementation.

I'll try to reproduce the issue in the demo project, since it needs to have a collectionView test anyway, and fix it.

phillip-martin commented 9 years ago

I ended up finding a workaround for my case in 0.10.0. In this situation I am placing a custom UITableViewController inside of a UITabBarController. Initially, my code looked like the following:

//TabBarController
- (void)viewDidLoad {
    [super viewDidLoad];

    self.tvc1 = [[CustomTableViewController alloc] init];
    self.tvc2 = [[CustomTableViewController alloc] init];

    self.viewControllers = @[self.tvc1, self.tvc2];
}

//CustomTableViewController
- (void)viewDidAppear:(BOOL)animated
{
    self.shyNavBarManager.scrollView = self.tableView;
}

This worked in 0.9.15; any time a tab was clicked and a different tableview appeared, the appropriate scrollview was set. The vibrations began when upgrading to 0.10.0. To fix this in 0.10.0, I had to set self.shyNavBarManager.scrollview in the TabBarController instead of inside CustomTableViewController. the following is what the new code looked like:

//TabBarController
- (void)viewDidLoad {
    [super viewDidLoad];

    self.tvc1 = [[CustomTableViewController alloc] init];
    self.tvc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"One" image:nil tag:1];
    self.tvc2 = [[CustomTableViewController alloc] init];
    self.tvc2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Two" image:nil tag:2];

    self.viewControllers = @[self.tvc1, self.tvc2];
}

- (void)viewDidAppear:(BOOL)animated
{
    self.shyNavBarManager.scrollView = self.tvc1.tableView;
}

-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    if(item.tag == 1)
    {
        self.shyNavBarManager.scrollView = self.tvc1.tableView;
    }
    if(item.tag == 2)
    {
        self.shyNavBarManager.scrollView = self.tvc2.tableView;
    }
}

//CustomTableViewController
- (void)viewDidAppear:(BOOL)animated
{
    //self.shyNavBarManager.scrollView = self.tableView;
}

I hope this information helps. I am not familiar enough with this project to know what this means, but my guess is that the issue has something to do with the view hierarchy.

Mazyod commented 9 years ago

Every detail absolutely helps, thanks! You are giving me hope that the issue is a result of working around a bug in the older version that is no longer there. This will give users an opportunity to clean their code after upgrading to 0.10.0

Still haven't had time to dig into this, but its on my priorities list.

Mazyod commented 9 years ago

Sorry, this got automatically closed by the commit .. I was able to reproduce it and fix it, thanks to someone who commented on the suspect being viewMaxY. They were right!

I will do some testing, and publish 0.10.1 soon. Thanks a lot for reporting this @dbleicher, @pmarti28 !

dbleicher commented 9 years ago

@Mazyod the new 0.10.1 works great. I really appreciate this library and the work you've done on it. Thanks!

Mazyod commented 9 years ago

@dbleicher Anytime! I appreciate you keeping up with the upgrades, as well!

(I blame email notifications for the initial late reply, but fixed that as well now)