Search code examples
iphoneiosuisplitviewcontrollernavigationbar

Issue in hiding UINavigationBar in ios


I have a split view controller in my app's contact page.. and i am unable to hide the navigation bar in my page.. Can anyone help me on hiding the navigationBar. i have attached my code

- (void)viewDidLoad
{
self.navigationController.navigationBarHidden = YES;
splitViewController.navigationController.navigationBarHidden = YES;

appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate]; 

[super viewDidLoad];

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
    [[VHeaderView sharedVHeaderView] viewWithCommonHeaderOnView1:self.view];
}
else
{
    [[VHeaderView_iPad sharedVHeaderView_iPad] viewWithCommonHeaderOnView1:self.view];

}

[splitViewController.view setFrame:CGRectMake(0,48, 768, 1024)];
  // [self.view removeFromSuperview];
//self.view.frame=CGRectMake(0,100, 768, 1024);
[self.view addSubview:splitViewController.view];


}

Solution

  • - (void)viewWillAppear:(BOOL)animated
    {
        [self.navigationController setNavigationBarHidden:YES animated:animated];
        [super viewWillAppear:animated];
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
        [self.navigationController setNavigationBarHidden:NO animated:animated];
        [super viewWillDisappear:animated];
    }
    
    put this code in your .m file
    

    if u don't wish to animated effect then set no.