iphone - Multiple UIBarButtonItems in UINavigationBar -
how create multiple bar button in navigation bar?
you must use uitoolbar , set toolbar buttons:
// create toolbar can place buttons uitoolbar *toolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0, 0, 100, 45)]; [toolbar setbarstyle: uibarstyleblackopaque]; // create array buttons nsmutablearray *buttons = [[nsmutablearray alloc] initwithcapacity:3]; // create standard save button uibarbuttonitem *savebutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemsave target:self action:@selector(saveaction:)]; savebutton.style = uibarbuttonitemstylebordered; [buttons addobject:savebutton]; // create spacer between buttons uibarbuttonitem *spacer = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace target:nil action:nil]; [buttons addobject:spacer]; // create standard delete button trash icon uibarbuttonitem *deletebutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemtrash target:self action:@selector(deleteaction:)]; deletebutton.style = uibarbuttonitemstylebordered; [buttons addobject:deletebutton]; // put buttons in toolbar , release them [toolbar setitems:buttons animated:no]; // place toolbar navigation bar self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:toolbar];
Comments
Post a Comment