Ios – View Frame Changes On Hide/Show Navigation Bar

cocoa-touchiosiphoneobjective cuinavigationcontroller

In My Application,

I have Navigation Controller with root view controller.

To show/hide navigation bar which works fine.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    BOOL navbarhide=[self.navigationController.navigationBar isHidden];
    [self.navigationController setNavigationBarHidden:!navbarhide animated:YES];


}

Works good but,

When navigation bar is hidden then view frame changes.

When navigation bar is not hidden then view frame changes.

When navigation bar is not hidden ..see the press button and view's origin is below the bar, I dont want like this I want it to stick at navigation bar's origin[at the top of the page]

It is fine view is at its original position when bar is hidden. I want view to be stick  at this position and turn bar hide/show without changing the view's frame.

Thanks in Advance…

Edit Setting set self.view.frame does not make any effect.

Best Answer

I have the same problem. In my project, it is because the view is scroll view. If your view is a scroll view or table view, you can try this:

I add below code to the controller.

self.automaticallyAdjustsScrollViewInsets = NO;

Hope it can help you.

Related Topic