Created
December 21, 2012 19:13
-
-
Save anonymous/4355052 to your computer and use it in GitHub Desktop.
Suggestion for a better UIActionSheet API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Action Sheet API with target/selector | |
ECActionSheet *actionSheet = [[ECActionSheet alloc] initWithTitle:@"Title" cancelButtonTitle:@"Cancel"]; | |
[actionSheet addDestructiveButtonWithTitle:@"Destructive Button" target:self selector:@selector(destructiveButtonPressed)]; | |
[actionSheet addButtonWithTitle:@"Button One" target:self selector:@selector(buttonOnePressed)]; | |
[actionSheet addButtonWithTitle:@"Button Two" target:self selector:@selector(buttonTwoPressed)]; | |
[actionSheet showInView:self.view]; | |
// Action Sheet API with blocks | |
ECActionSheet *actionSheet = [[ECActionSheet alloc] initWithTitle:@"Title" cancelButtonTitle:@"Cancel"]; | |
[actionSheet setDestructiveButtonWithTitle:@"Destructive Button" onTapped:^{ | |
// do something when destructive button is tapped | |
}]; | |
[actionSheet addButtonWithTitle:@"Button One" onTapped:^{ | |
// do something when button one is tapped | |
}]; | |
[actionSheet addButtonWithTitle:@"Button Two" onTapped:^{ | |
// do something when button one is tapped | |
}]; | |
[actionSheet showInView:self.view]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment