3

I have been googling this issues since forever. I have a table view controller with navigation bar and a tool bar at the bottom. I am able to show the tool bar

self.navigationController.toolbaHidden = NO;

I then added some items to the toolbar like this

UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
button.titleLabel.text = @"Button";
UIBarButtonItem *buttonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease];
[self setToolbarItems:[NSArray arrayWithObject:buttonItem] animated:NO];
[button release];

However it never works. I think it is the correct way to do but somehow it shows nothing on the toolbar. Does anyone know what the reason is? Or if you know a correct way to add tool bar items please let me know? Thanks a lot guys.

Cheers,

danh
  • 62,181
  • 10
  • 95
  • 136
Jeremy
  • 63
  • 3

1 Answers1

5
 UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
     UIBarButtonItem *buttonItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:nil];
  self.toolbarItems=[NSArray arrayWithObjects:buttonItem,buttonItem2,nil];
    self.navigationController.toolbarHidden = NO;

it seems that because you are adding the round button in the barbutton it is not displaying,try to add the toolbar with system provided barbuttons it will surely work

sujith1406
  • 2,822
  • 6
  • 40
  • 60