-1

i am new in objective-c .I am trying to hide navigationbar i used this code and it's work perfectly but problem is this when i hide navigationbar after i am failed to show navigationItem's rightBarButtonItem

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.navigationController.navigationBarHidden = YES;
   // self.navigationItem.rightBarButtonItem.enabled = NO;

}

i am used this code for navigationItem

-(void)loadBackButton{
     /*UIBarButtonSystemItemDone */
     buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(dismiss:)];
     self.navigationItem.rightBarButtonItem = buttonItem;

}

- (void)dismiss:(id)sender {
    NSLog(@"Dismis Done");
    [self dismissModalViewControllerAnimated:YES];
    //[self.view removeFromSuperview];
}

and my - (void)viewDidLoad are bellow

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
     //for load navigationItem's 
    [self loadBackButton];
    self.navigationItem.rightBarButtonItem.enabled = YES;

    // Do any additional setup after loading the view from its nib.
}
John
  • 2,820
  • 3
  • 30
  • 50
Ferrakkem Bhuiyan
  • 2,741
  • 2
  • 22
  • 38
  • You can't see "rightBarButtonItem" but it is inside your Navigation bar – Munahil Aug 06 '15 at 12:23
  • i hide my Navigation bar ..i just want to show my rightBarButtonItem.. i don't need Navigation bar – Ferrakkem Bhuiyan Aug 06 '15 at 12:26
  • 1
    This question makes no sense. You have put buttons on navigation bar and then if you hide the navigation bar what do you think will happen to the buttons? They will be hidden as well as they are on navigation bar. This is not rocket science. – Sam B Aug 06 '15 at 12:29
  • Why dont you make it transparent? – Munahil Aug 06 '15 at 12:29

1 Answers1

2

Hiding NavigationBar will hide your rightBarButtonItem too. One of the possible solutions is that you make the Navigation Bar transparent. You can use following code to do so:

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
Munahil
  • 2,381
  • 1
  • 14
  • 24