1

I saw in the documentation that now you can have an array of items for the leftBarButtonItems and rightBarButtonItems in a UINavigationController and don't have to create a UIToolBar and set that as the button. I basically want a "Home" button on the left next to the "back" button of the navigationController. So it would look like:

BackButtonFromNavigationController HomeBarButtonItem

I wasn't sure how I get the navigationBar's backButton into my array once I create my HomeButton. I tried this, but I only see the navigationController's backBarButton:

if ([self.navigationItem respondsToSelector:@selector(setLeftBarButtonItems:)]) {
    UIBarButtonItem *hButton = [self createHomeButton];
    self.navigationController.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:self.navigationItem.backBarButtonItem, hButton, nil];
}

Edited per smparkes response:

if ([self.navigationItem respondsToSelector:@selector(leftItemsSupplementBackButton)]) {
    self.navigationItem.leftItemsSupplementBackButton = YES;
    self.navigationItem.leftBarButtonItem = homeBBI;
}

I know homeBBI is created properly as I have it in my UIToolBar as the rightBarButtonItem prior to iOS 5. Now I'm just trying to move it to the left and I used the same button to see if it would work but it doesn't seem to work still...

2 Answers 2

8

Don't put the back button in the array. Use leftItemsSupplementBackButton to make the button array add to instead of replace the back button. Once you've done that, it doesn't sound like you even need an array.

I think you're getting the behavior you are seeing because your button array is empty. You're adding self.navigationItem.backBarButtonItem which is probably nil. You want the back button from the controller one step deeper in the nav stack, not the back button for the current controller.

Sign up to request clarification or add additional context in comments.

2 Comments

It looks okay, as long as homeBBI is not nil (did you double check)? Otherwise, not sure.
yeah i checked it for not being nil and still doesn't show up unfortunately. Will keep checking. Thanks for the response though!
0

I had the same problem. In my case the reason for hiding the additional buttons was that I've been using a custom title view. As the documentation states:

If there is not enough room to display all of the items in the array, those that would overlap the title view (if present) or the buttons on the right side of the bar are not displayed.

Changing the size of the custom title view did resolve my problems. Perhaps this hint will help others.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.