how do I add by code on a button to a toolbar that I have the property?
@property (strong, nonatomic) IBOutlet UIToolbar *toolB;
how do I add by code on a button to a toolbar that I have the property?
@property (strong, nonatomic) IBOutlet UIToolbar *toolB;
UIBarButtonItem *buttonOne = [[UIBarButtonItem alloc] initWithTitle:@"Button One" style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
UIBarButtonItem *buttonTwo = [[UIBarButtonItem alloc] initWithTitle:@"Button Two" style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
NSArray *buttons = [NSArray arrayWithObjects: buttonOne, buttonTwo, nil];
[toolBar setItems: buttons animated:NO];
Will do the trick if i understand correctly what you are asking. action
being the method you want the buttons to call.
This may help you, dont forget to release Buttons.
UIToolbar *actionToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 416, 320, 44)];
UIBarButtonItem *actionButton =
[[[UIBarButtonItem alloc]
initWithTitle:@"No Action"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(noAction:)]
autorelease];
[actionToolbar setItems:[NSArray arrayWithObject:actionButton]];
UIToolbar dont have side buttons, you can use UINavigationBar or follow this link