0

I am adding a custom UIImageView to my UINavigationBar using this code:

UIImageView *background = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease];
[background setImage:[UIImage imageNamed:@"nav_background.png"]];
[background setTag:kTagForReference];
[self.navigationController.navigationBar insertSubview:background atIndex:0];

I then add a custom title using this code:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 400, 44)];
... 
[self.navigationItem setTitleView:label];
[label release];

But on some of my pushed views the title is being hidden (or isn't visible). I can't seem to push more than two views onto the stack without the title disappearing.

I've tried to force my UIImageView background to the back of the bar but that still doesn't help. I've printed the subviews of the UINavigationBar and I can see that the UILabel is there, I just can't see it!

Any help would be greatly appreciated.

Ricky
  • 3,101
  • 1
  • 25
  • 33

2 Answers2

0

If you can run the dumpWindows() function, the output would show the view hierarchy so you can see what view is covering it up.

Community
  • 1
  • 1
progrmr
  • 75,956
  • 16
  • 112
  • 147
0

You most likely want to use a UIToolBar instead of a NavigationBar. Then you can add the subviews to the UIToolbar.

Bring the UILabel to the front most view.

[self.view bringSubviewToFront: label];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • If I used a `UIToolbar`, then what would happen to all my navigation stack? – Ricky Sep 09 '11 at 02:29
  • As long as you add the UIToolbar to your controller, and just hide the NavigationBar, absolutely nothing. You can even setup a "Back" or "Done" button to either pop or dismiss said navigationController. – WrightsCS Sep 09 '11 at 02:30