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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to