• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Two right buttons on UINavigationBar?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two right buttons on UINavigationBar?


  • Subject: Re: Two right buttons on UINavigationBar?
  • From: Steven Arnold <email@hidden>
  • Date: Wed, 12 Aug 2009 14:49:45 -0400

On Thu, 6 Aug 2009 14:03:12 -0400, Hank Heijink wrote:
If one of your buttons is always hidden, why do you need two buttons? You can just use one button and change the title, target, and action when you need to. If necessary you can even replace the whole button.

On Aug 6, 2009, at 1:47 AM, Agha Khan wrote:

Hi:
I have a UINavigationBar where I would like to place 2 buttons.

I have a use case for needing two buttons. I need a button to add a new item and a button to edit (including delete and move around) existing items. It's a UINavigationBar, so I am using the backBarButtonItem to traverse backward up the hierarchy. On the right- hand side, I'd like to have two buttons next to one another, one with a UIBarButtonSystemItemEdit icon and the other with a UIBarButtonSystemItemAdd icon.


The closest I have come was trying to use a custom UIView:

    UIButton *editButton = [[UIButton alloc]
            initWithFrame:CGRectMake(0,0,100,75)];
    editButton.titleLabel.text = @"Edit";
    UIButton *backButton = [[UIButton alloc]
            initWithFrame:CGRectMake(100,0,100,75)];
    backButton.titleLabel.text = @"Back";

    UIView *backAndEditButtons = [[UIView alloc] init];
    // Add two buttons to view
    [backAndEditButtons addSubview:backButton];
    [backAndEditButtons addSubview:editButton];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
            initWithCustomView:backAndEditButtons];

This doesn't work: I see nothing at all on the right-hand side of the UINavigationBar.

I am new at manipulating UIViews, so any corrections to the code above are welcome. Also if anyone feels I should try an entirely different approach to solving the problem, I'm interested.

steven

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Two right buttons on UINavigationBar?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: NSOutlineView vertical text alignment
  • Next by Date: Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
  • Previous by thread: Re: Two right buttons on UINavigationBar?
  • Next by thread: Re: Two right buttons on UINavigationBar?
  • Index(es):
    • Date
    • Thread