views:

99

answers:

0

I need two buttons on the left side of a nav bar. The only way I've figured out how to do that is by first putting them into a UIToolbar and then setting the leftBarButtonItem to that.

If I do this it works as normal (you can see it highlight when tapped):

UIBarButtonItem* myBtn = [[UIBarButtonItem alloc] initWithTitle:@"Button" style:UIBarButtonItemStyleBordered target:self action:@selector(doSomething:)];

self.navigationItem.leftBarButtonItem = myBtn;

But if I do it like this, the button action still happens but there is no highlight (no visual feedback that you are tapping the button):

 NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];

 UIBarButtonItem* myBtn = [[UIBarButtonItem alloc] initWithTitle:@"Button" style:UIBarButtonItemStyleBordered target:self action:@selector(doSomething:)];

 UIBarButtonItem* myBtn2 = [[UIBarButtonItem alloc] initWithTitle:@"Button2" style:UIBarButtonItemStyleBordered target:self action:@selector(doSomethingElse:)];

 [buttons addObject:myBtn];
 [buttons addObject:myBtn2];

 UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44)];
 [toolbar setItems:buttons animated:NO];
 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar];

Any idea why this causes the buttons to not highlight when touched?