I am new to iPhone development.
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"SAVE"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(saveButtonClicked)];
self.navigationItem.rightBarButtonItem = saveButton;
by using the above , i can create navigation rightbarbuttonitem but i cant add more items into it...i need to add more buttons
please provide me a sample code to try it out
Thanks for any help and thanks for your time
Add tool bar to Navigation bar
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];
tools.tintColor = [UIColor blackColor];
// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
// create a standard "add" button
bi = [[UIBarButtonItem alloc]
initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(addMedicine)];
[buttons addObject:bi];
[bi release];
// create a spacer
bi = [[UIBarButtonItem alloc]
initWithTitle:@"Edit" style:UIBarButtonSystemItemEdit target:self action:@selector(edit)];
[buttons addObject:bi];
[bi release];
// stick the buttons in the toolbar
[tools setItems:buttons animated:NO];
[buttons release];
// and put the toolbar in the nav bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
All the best.
Use DDActionHeaderView . You can add and manage items easily.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.