Hiding a navigation bar like instagram or Facebook on iPhone?

I had an application in which I want to hide the navigation bar when scrolling up to UITableView. I do 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 completely moving up in iOS 7. I need it to be stopped in the status bar, and the status bar is displayed there.

+4
source share
1 answer
+1
source

All Articles