views:

634

answers:

2

I have a reference to a "UIBarButtonItem", is there a way I can add a custom "Back Navigation Button" to that item when it is not part of a Navigation based view?

I can add a left button:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] 
initWithTitle:@"Custom Back" 
style:UIBarButtonItemStylePlain target:self
action:@selector(backAction:)];

menuItem.backBarButtonItem = backButton; //This doesn't seem to work.

menuItem.popOverNavigationItem.leftBarButtonItem = backButton; //This shows a normal button

So how could I make the leftmost button look like a back navigation button?

UPDATE: This other question answered the root of my problem that was leading me to try and do this non-standard UI setup:
http://stackoverflow.com/questions/2662833/ipad-merge-concept-of-splitviewcontroller-and-navigationcontroller-in-rootview

+2  A: 

I think the correct way to set the back button is to set it for the view controller that you would be going back to. For example:

RootViewController > DetailViewController

If you want the back button to say "Custom Back" whilst you're on DetailViewController, you have to actually set RootViewController's back button to "Custom Back".

Hope that makes sense.

Tom Irving
I don't think that's right. The closest thing to this is setting the `title` property of the `RootViewController` to be the text that appears on the back button of `DetailViewController`. Edit: Seems to be right. Have a look: http://www.retainrelease.com/blog/?p=11
bddckr
My question is if you could do this to a NavBarItem without using the NavBarController. (This comes up in the SplitViewController example code.)
MikeN
Not without a nav controller, but you don't have to always have a nav bar with a nav controller, so why not have a navigation controller?
Kendall Helmstetter Gelner
A: 

Having just struggled with this: I think the answer is “no.” You'll need a controller hierarchy.

David Dunham