Question

It seems that I am doing something wrong, but I don't understand what. I have UIViewController and here is it's viewDidLoad method:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationController.navigationBarHidden=NO;

    // tableview initialisation

    // search bar initialisation

   menu = [[SINavigationMenuView alloc] initWithFrame:CGRectMake(-10, 0, 200, self.navigationController.view.frame.size.height) title:NSLocalizedString(@"ALBUMS", nil)];
   [menu displayMenuInView:self.view];
   menu.tableFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);


   menu.items = @[NSLocalizedString(@"ALL", nil), NSLocalizedString(@"DOWNLOADS", nil), ...];

   menu.delegate = self.controller;
   self.navigationItem.titleView = menu;

   //sidebar button
   UIImage *sidebarButtonImage = [UIImage imageNamed:@"menu"];
   UIButton * sidebarButton = [UIButton buttonWithType:UIButtonTypeCustom];
   sidebarButton.bounds = CGRectMake(0, 0, sidebarButtonImage.size.width, sidebarButtonImage.size.height);
   [sidebarButton setImage:sidebarButtonImage forState:UIControlStateNormal];
   [sidebarButton addTarget:self action:@selector(onMenuPressed:) forControlEvents:UIControlEventTouchUpInside];
   UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:sidebarButton];
   [self.navigationItem setLeftBarButtonItem:leftButton];
}

After loading this view navigationBar does not appear.

Était-ce utile?

La solution

Your view controller must be inside of a navigation controller. Make sure your view controller is the root view or one of the view controllers in self.navigationController.viewcontrollers

If it is not contained inside of a navigation controller, you will have no bar.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top