4

I had an application in which I want to hide my navigation bar when scrolling upwards in a UITableView. I am doing like this

- (void)scrollViewDidScroll:(UIScrollView *)sender {

    //Initializing the views and the new frame sizes.
    UINavigationBar *navbar = self.navigationController.navigationBar;
    UIView *tableView = self.view;

    CGRect navBarFrame = self.navigationController.navigationBar.frame;
    CGRect tableFrame = self.view.frame;

    //changing the origin.y based on the current scroll view.
    //Adding +20 for the Status Bar since the offset is tied into that.
    navBarFrame.origin.y = MIN(0, (sender.contentOffset.y * -1)) +20;
    navbar.frame = navBarFrame;

    tableFrame.origin.y = MIN(0,MAX(-44,(sender.contentOffset.y * -1)));
    tableView.frame = tableFrame;    
}

But the problem is that it is moving completely upwards in iOS 7. I need it to be stopped under the status bar and the status bar is shown there.

Wain
  • 118,658
  • 15
  • 128
  • 151
hacker
  • 8,919
  • 12
  • 62
  • 108
  • 2
    have a look at this library https://github.com/andreamazz/AMScrollingNavbar – The dude Jan 14 '14 at 14:20
  • 1
    Have you tried any of these solutions? http://stackoverflow.com/questions/19819165/imitate-ios-7-facebook-hide-show-expanding-contracting-navigation-bar – David Omid Jan 14 '14 at 14:20
  • i tried all of them,in the first one when scrolling starts content offset is changing not coming back to 0 – hacker Jan 14 '14 at 14:26
  • The project mentioned by @Thedude is pretty easy to use. But when the navigation bar reappears, there is a gap added between the tableview and the navigation bar. How do I prevent/remove that gap? – Katedral Pillon Sep 14 '14 at 21:41
  • @KatedralPillon A comment in one question is not the place to ask another question. Try asking a new question with details of your issue to get some help. – The dude Sep 15 '14 at 07:14
  • @Thedude I did: http://stackoverflow.com/questions/25839112/a-more-complete-library-to-contract-expand-navigation-bar – Katedral Pillon Sep 15 '14 at 07:25
  • Did you try ` self.navigationController.hidesBarsOnSwipe = YES;` on your viewDidAppear method? – Husein Behboudi Rad May 24 '15 at 05:25

1 Answers1

1

https://github.com/ninjinkun/NJKScrollFullScreen ...Hope this will help any other

Apple_Magic
  • 477
  • 8
  • 26