Guest User

Untitled

a guest
Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. // create a toolbar where we can place some buttons
  2. UIToolbar* toolbar = [[UIToolbar alloc]
  3. initWithFrame:CGRectMake(0, 0, 100, 45)];
  4. [toolbar setBarStyle: UIBarStyleBlackOpaque];
  5.  
  6. // create an array for the buttons
  7. NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];
  8.  
  9. // create a standard save button
  10. UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
  11. initWithBarButtonSystemItem:UIBarButtonSystemItemSave
  12. target:self
  13. action:@selector(saveAction:)];
  14. saveButton.style = UIBarButtonItemStyleBordered;
  15. [buttons addObject:saveButton];
  16. [saveButton release];
  17.  
  18. // create a spacer between the buttons
  19. UIBarButtonItem *spacer = [[UIBarButtonItem alloc]
  20. initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
  21. target:nil
  22. action:nil];
  23. [buttons addObject:spacer];
  24. [spacer release];
  25.  
  26. // create a standard delete button with the trash icon
  27. UIBarButtonItem *deleteButton = [[UIBarButtonItem alloc]
  28. initWithBarButtonSystemItem:UIBarButtonSystemItemTrash
  29. target:self
  30. action:@selector(deleteAction:)];
  31. deleteButton.style = UIBarButtonItemStyleBordered;
  32. [buttons addObject:deleteButton];
  33. [deleteButton release];
  34.  
  35. // put the buttons in the toolbar and release them
  36. [toolbar setItems:buttons animated:NO];
  37. [buttons release];
  38.  
  39. // place the toolbar into the navigation bar
  40. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
  41. initWithCustomView:toolbar];
  42. [toolbar release];
Add Comment
Please, Sign In to add comment