Posted By

BenClayton on 04/21/10


Tagged


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

avanadra
bornykd
umang_nine
rvachere
sb
nsbuckner
aday
im3der
wpellis
cnathan


iphone UIActionSheet - pop up list of options


 / Published in: Objective C
 

  1. // place this code in a UIViewController subclass
  2.  
  3. - (void)debugButtonPressed:(id)sender
  4. {
  5. UIActionSheet* action = [[UIActionSheet alloc]
  6. initWithTitle:@"Menu"
  7. delegate:self
  8. cancelButtonTitle:@"Continue"
  9. destructiveButtonTitle:@"Quit"
  10. otherButtonTitles:@"Debug",nil ];
  11. [action showInView:self.view];
  12. [action release];
  13. }
  14.  
  15. - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
  16. switch (buttonIndex) {
  17. case 0: // continue
  18. NSLog(@"Continue");
  19. break;
  20. case 1: // Quit
  21. NSLog(@"Quit");
  22. break;
  23. case 2: // Debug
  24. NSLog(@"Debug");
  25. break;
  26. }
  27. }

Report this snippet  

You need to login to post a comment.