/ Published in: Objective C
Here's a quick snippet for popping up a list of options using the UIActionSheet in iPhone OS.
What's slightly confusing is that the index of the 'cancelButton' is 1, and 'destructiveButton' is 0, even though 'cancelButton' is listed first in the initWithTitle selector. This gets me each time!
What's slightly confusing is that the index of the 'cancelButton' is 1, and 'destructiveButton' is 0, even though 'cancelButton' is listed first in the initWithTitle selector. This gets me each time!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// place this code in a UIViewController subclass - (void)debugButtonPressed:(id)sender { UIActionSheet* action = [[UIActionSheet alloc] initWithTitle:@"Menu" delegate:self cancelButtonTitle:@"Continue" destructiveButtonTitle:@"Quit" otherButtonTitles:@"Debug",nil ]; [action showInView:self.view]; [action release]; } - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { switch (buttonIndex) { case 0: // Quit NSLog(@"Quit"); break; case 1: // Continue NSLog(@"Continue"); break; case 2: // Debug NSLog(@"Debug"); break; } }