4

I have a navigationBar, with a UIImage on it's title, like this:

self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top_logo.png"]];

When i select a row, the "back" button does not appear. Why?

I have the exact same code on other's viewControllers, and it appears. I don't understand why...

Thanks,

RL

Vladimir
  • 170,431
  • 36
  • 387
  • 313
Rui Lopes
  • 2,562
  • 6
  • 34
  • 49

2 Answers2

9

The back button won't appear unless you've set self.navigationItem.title or 'self.title' in the previous view controller on the stack (parent VC) or explicitly created a UIBarButtonItem and set it to self.navigationItem.backBarButtonItem in the previous view controller on the stack (parent VC).

benwong
  • 2,226
  • 1
  • 16
  • 14
  • @benwong Hi, the title is set like this: detailViewController.title=NSLocalizedString(@"Info", @"info"); – Rui Lopes Feb 06 '11 at 21:51
  • The title of the view controller is different from the title of the view controller navigation item. – benwong Feb 06 '11 at 21:56
  • @benwong Hi. Parent VC: self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"top_logo.png"]]; Child VC (called in Partent VC didSelectRow... method): chamadasDetalhe.title=NSLocalizedString(@"Info", @"info"); when the child is pushed, there's no back button... – Rui Lopes Feb 06 '11 at 21:59
  • Ok. I just tested a couple of things myself. self.title works as well. – benwong Feb 06 '11 at 23:02
  • That would be assuming too much. The titleView doesn't have to be an UIImageView. If it was a UISegmentedControl for example, it wouldn't make much sense to make that into a back button. – benwong Feb 07 '11 at 23:20
0

did you push the new view through the navigation stack?

like:

[self.navigationController pushViewController:viewControllerToPush animated:YES];

Claudio Martins
  • 617
  • 1
  • 6
  • 12