Skip to content

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality from Safari on iPhone/ iOS / CocoaTouch.

License

Notifications You must be signed in to change notification settings

JaseElder/ActionSheetPicker-3.0

 
 

Repository files navigation

Since the main repo not updated for a year:

I'm gonna go build my own ActionSheetPicker, with blackjack and hookers. (c)

pod 'ActionSheetPicker-3.0', '~> 1.0.7

New ActionSheetPicker, with fix crashes, new pickers and additions. I merge most of all fixes to TimCinel's branch already.

Regards, Petr Korolev

ActionSheetPicker = UIPickerView + UIActionSheet

Well, that's how it started. Now, the following is more accurate:

  • iPhone/iPod ActionSheetPicker = ActionSheetPicker = A Picker + UIActionSheet
  • iPad ActionSheetPicker = A Picker + UIPopoverController

Overview

ActionSheetPicker https://github.com/TimCinel/ActionSheetPicker

Easily present an ActionSheet with a PickerView, allowing user to select from a number of immutable options. Based on the HTML drop-down alternative found in mobilesafari.

Improvements more than welcome - they are kindly requested :)

Benefits

  • 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)

QuickStart

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.

Basic Usage:

// 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];

But you probably want to know when something happens, huh?

// 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

Screen Shots

ActionSheetPicker ActionSheetDatePicker ActionSheetDistancePicker iPad Support

Credits

Thanks to all of the contributors for making ActionSheetPicker better for the iOS developer community. See AUTHORS for details.

Contributors

Filote Stefan

Brett Gibson

John Garland (iPad!)

Mark van den Broek

Evan Cordell

Greg Combs (Refactor!)

Petr Korolev (Update, crash-fix update for iOS7, new pickers)

Creator

Tim Cinel

@TimCinel

timcinel.com/

About

Quickly reproduce the dropdown UIPickerView / ActionSheet functionality from Safari on iPhone/ iOS / CocoaTouch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 94.2%
  • C++ 4.1%
  • Ruby 1.7%