#Added new picker ActionSheetMonthYearPicker that you can set the start year-month and end year-month.
ActionSheetMonthYearPicker *actionSheet = [[ActionSheetMonthYearPicker alloc] initWithTitle:@"Expire"
start:@"2012.06"
end:@"2015.10"
tartget:self
successAction:@selector(monthAndYearSelected:)
cancelAction:nil origin:sender];
[actionSheet showActionSheetPicker];
[actionSheet release];
- (void)monthAndYearSelected:(NSString*)selectedDate
{
NSLog(@" >> %@ has selected",selectedDate);
}
Well, that's how it started. Now, the following is more accurate:
- iPhone/iPod ActionSheetPicker = ActionSheetPicker = A Picker + UIActionSheet
- iPad ActionSheetPicker = A Picker + UIPopoverController
ActionSheetPicker https://github.com/TimCinel/ActionSheetPicker
Easily present an ActionSheet with a PickerView, allowing user to select from a number of immutible options. Based on the HTML drop-down alternative found in mobilesafari.
Improvements more than welcome - they are kindly requested :)
- Spawn pickers with convenience function - delegate or reference not required. Just provide a target/action callback.
- Add buttons to UIToolbar for quick selection (see ActionSheetDatePicker below)
- Delegate protocol available for more control
- Universal (iPhone/iPod/iPad)
There are 4 distinct picker view options: ActionSheetStringPicker
, ActionSheetDistancePicker
, ActionSheetDatePicker
, and ActionSheetCustomPicker
. We'll focus here on how to use the ActionSheetStringPicker
since it's most likely the one you want to use.
// Inside a IBAction method:
// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];
[ActionSheetStringPicker showPickerWithTitle:@"Select a Color"
rows:colors
initialSelection:0
doneBlock:nil
cancelBlock:nil
origin:sender];
// Inside a IBAction method:
// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];
[ActionSheetStringPicker showPickerWithTitle:@"Select a Color"
rows:colors
initialSelection:0
doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
NSLog(@"Picker: %@", picker);
NSLog(@"Selected Index: %@", selectedIndex);
NSLog(@"Selected Value: %@", selectedValue);
}
cancelBlock:^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
}
origin:sender];
// You can also use self.view if you don't have a sender
Thanks to all of the contributors for making ActionSheetPicker better for the iOS developer community. See AUTHORS for details.
John Garland (iPad!)
Greg Combs (Refactor!)
Petr Korolev (Update, crashfix, update for iOS7, new pickers)