[英]issue in hiding navigation bar
i add navigation bar in rootController like below in appdelegate 我在rootController中添加导航栏,如下所示在appdelegate中
@property (strong, nonatomic) UINavigationController *navController;
@synthesize navController;
birthDateTableViewController =[[BirthDateTableViewController alloc]initWithNibName:@"BirthDateTableViewController" bundle:nil];
navController = [[[UINavigationController alloc]initWithRootViewController:birthDateTableViewController]autorelease];
[window addSubview:navController.view];
[window makeKeyAndVisible];
return YES;
now as i want to hide it in other view because they have their own navigation bars so i use following code for hiding rootViewControllers navigation bar but its not hiding please tell me what i am doing wrong i do this for hiding in viewDidLoad 现在,因为我要在其他视图中隐藏它,因为它们有自己的导航栏,所以我使用以下代码隐藏rootViewControllers导航栏,但它没有隐藏,请告诉我我在做什么错了我这样做是为了隐藏在viewDidLoad中
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.navController setNavigationBarHidden: YES animated:NO];
application get crash when it reach above line i have tried this which is not working [self.navigationController setNavigationBarHidden: YES animated:NO]; 当应用程序到达上面的行时,应用程序崩溃了。我尝试了这不起作用的方法[self.navigationController setNavigationBarHidden:YES animation:NO];
Your appDelegate doesn't have a link to the navController but your viewController has one! 您的appDelegate没有到navController的链接,但是您的viewController有一个! So change your code for:
因此,将代码更改为:
[self.navigationController setNavigationBarHidden: YES animated:NO];
我认为这样会很好。
[self.navigationController setNavigationBarHidden: YES animated:YES];
Try this in your view controller's -(void)viewWillAppear method in which you don't want to show navigation bar. 在您不想显示导航栏的视图控制器的-(void)viewWillAppear方法中尝试此操作。
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = YES;
[super viewWillAppear:animated];
}
Rather using... 而是使用...
[window addSubview:navController.view];
Use this... 用这个...
[window addSubview:self.navController];
And in your viewControllers, use this... 在您的viewControllers中,使用此...
self.navigationController.navigationBarHidden = YES;
For iOS < 6.0 use 对于iOS <6.0使用
[self.window addSubview:navigationController.view];
For iOS >= 6.0 use 对于iOS> = 6.0使用
[self.window setRootViewController:navigationController];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.