0

我的应用程序的联系人页面中有一个拆分视图控制器。我无法在我的页面中隐藏导航栏。任何人都可以帮助我隐藏导航栏。我附上了我的代码

- (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];


}
4

3 回答 3

2

试试这个。为我工作。确保已分配导航控制器。

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];  
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    [self.navigationController setNavigationBarHidden:NO]; 
}
于 2013-10-04T12:23:55.623 回答
1
- (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

如果你不希望动画效果然后设置否。

于 2013-10-04T11:41:27.377 回答
0

此方法仅调用一次。

尝试将您的代码放入 ViewWillAppear

-(void)viewWillAppear:(BOOL)animated
{

[self.navigationController setNavigationBarHidden:YES animated:animated];

}

试试这个代码

于 2013-10-04T11:36:31.990 回答