Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.

Overview

ActionSheetPicker-3.0

Version Carthage compatible Build Status Issues License PlatformAll Contributors

Important update

Now I fixed most of the things and merge PR' (thanks to All Contributors).

I did much work to support this library from iOS 5. (and till iOS 13 and we keep going) πŸš€

I still need help with the future support of this repo. If you are interested to help - please drop a comment into issue #348 πŸ™

Regards, Petr Korolev


Please welcome: ActionSheetPicker-3.0!

ActionSheetPicker = UIPickerView + UIActionSheet

Animation

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

Easily present an ActionSheet with a PickerView, allowing the user to select from a number of immutable options.

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

We'll focus here on how to use the ActionSheetStringPicker since it's most likely the one you want to use.

Basic Usage

For detailed info about customizations, please look BASIC USAGE

  • Custom buttons view
  • Custom buttons callbacks
  • Action by clicking outside of the picker
  • Background color and blur effect
  • Other customizations

For detailed examples, please check Example Projects in this repo.

Swift

 ActionSheetMultipleStringPicker.show(withTitle: "Multiple String Picker", rows: [
            ["One", "Two", "A lot"],
            ["Many", "Many more", "Infinite"]
            ], initialSelection: [2, 2], doneBlock: {
                picker, indexes, values in

                print("values = \(values)")
                print("indexes = \(indexes)")
                print("picker = \(picker)")
                return
        }, cancel: { ActionMultipleStringCancelBlock in return }, origin: sender)

Objective-C

// Inside a IBAction method:

// Create an array of strings you want to show in the picker:
    NSArray *colors = @[@"Red", @"Green", @"Blue", @"Orange"];

// Done block:
    ActionStringDoneBlock done = ^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
        NSLog(@"Picker: %@", picker);
        NSLog(@"Selected Index: %@", @(selectedIndex));
        NSLog(@"Selected Value: %@", selectedValue);
    };


// cancel block:
    ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) {
        NSLog(@"Block Picker Canceled");
    };

// Run!
    [ActionSheetStringPicker showPickerWithTitle:@"Select a Color" rows:colors initialSelection:0 doneBlock:done cancelBlock:cancel origin:sender];

Installation

CocoaPods

pod 'ActionSheetPicker-3.0'

(iOS 5.1.1-13.x compatible!)

CocoaPods is a dependency manager for Cocoa projects.

You can install it with the following command:

gem install cocoapods

To integrate ActionSheetPicker-3.0 into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'ActionSheetPicker-3.0'

Then, run the following command:

pod install

Import to project

To import pod you should add string:

  • For Obj-c projects:
   #import "ActionSheetPicker.h"
  • For Swift projects:
  import ActionSheetPicker_3_0

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

brew update
brew install carthage

To integrate ActionSheetPicker-3.0 into your Xcode project using Carthage, specify it in your Cartfile:

github "skywinder/ActionSheetPicker-3.0"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into Xcode and the Swift compiler.

If you are using Xcode 11 or later:

  1. Click File
  2. Swift Packages
  3. Add Package Dependency...
  4. Specify the git URL for ActionSheetPicker-3.0.
https://github.com/skywinder/ActionSheetPicker-3.0

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate ActionSheetPicker-3.0 into your project manually.

The "old school" way is manually added to your project all from Pickers folder.

Embedded Framework

  • Add ActionSheetPicker-3.0 as a submodule by opening the Terminal, cd-ing into your top-level project directory, and entering the following command:
git submodule add https://github.com/skywinder/ActionSheetPicker-3.0.git
  • Open the ActionSheetPicker-3.0 folder, and drag CoreActionSheetPicker.xcodeproj into the file navigator of your app project.
  • In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
  • Ensure that the deployment target of CoreActionSheetPicker.framework matches that of the application target.
  • In the tab bar at the top of that window, open the "Build Phases" panel.
  • Expand the "Target Dependencies" group, and add CoreActionSheetPicker.framework.
  • Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add CoreActionSheetPicker.framework.

Example Projects

open ActionSheetPicker-3.0.xcworkspace

Here is 3 projects:

  • CoreActionSheetPicker - all picker files combined in one Framework. (available since iOS 8)
  • ActionSheetPicker - modern and descriptive Obj-C project with many examples.
  • Swift-Example - example, written on Swift. (only with basic 3 Pickers examples, for all examples please run ActionSheetPicker project)

Screenshots

ActionSheetPicker ActionSheetDatePicker ActionSheetDatePicker CustomButtons iPad Support

Apps using this library

If you've used this project in a live app, please let me know! Nothing makes me happier than seeing someone else take my work and go wild with it.

If you are using ActionSheetPicker-3.0 in your app or know of an app that uses it, please add it to this list.

Maintainer and Contributor

  • Petr Korolev (update to iOS 7 and iOS 8, implementing new pickers, community support). I did much work to support this library from iOS 5. (and till iOS 13 and we keep going πŸš€ ).

Now I fixed most of the things and merge PR' (thanks to All Contributors!).

I still need help with the future support of this repo. If you are interested to help - please drop a comment into issue #348 πŸ™

Contributing

  1. Create an issue to discuss your idea
  2. Fork it https://github.com/skywinder/ActionSheetPicker-3.0/fork
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Bug reports, feature requests, patches, well-wishes, and rap demo tapes are always welcome.

Discord

We have a Discord channel where discuss about new ideas and implementation. Feel free to join and discuss with us!

You can join our Discord using this link.

Credits

  • ActionSheetPicker was originally created by Tim Cinel (@TimCinel) Since the Tim's repo is not support iOS 7+, I forked from his repo and implement iOS 7-8 support, and also a bunch of UI fixes, crash-fixes, and different customization abilities.

  • And most of all, thanks to ActionSheetPicker-3.0's growing list of contributors.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Petr Korolev

πŸ’» πŸ‘€ πŸ’¬ πŸ’‘

Tim Cinel

πŸ’» πŸ‘€ πŸ“–

JurΔ£is ΔΆirΕ‘akmens

πŸ’¬ πŸ’‘

Nikos

πŸ“–

Vinh Tran

πŸ’» πŸ›‘οΈ

Kashif Hisam

πŸ’»

DYY_Xiaoer

πŸ’» πŸ›‘οΈ

Seth Delackner

πŸ’»

Zheng Li

πŸ’»

Andrea

πŸ’¬ πŸ’» πŸ–‹ 🚧

Bino90

πŸ’»

arnoldxt

πŸ’»

Koji Hasegawa

πŸš‡

Ali Ersoz

πŸ’»

KAWASHIMA Yoshiyuki

πŸ“–

Ricardo Hernandez

πŸ’»

Vincent Narbot

πŸ“–

Ezequiel França

πŸ“–

Nikola Mladenovic

πŸ“–

Umer Asif

πŸ›

longjun

πŸ’»

Manuel Kunz

πŸ’» πŸ‘€ πŸ“–

Noor ul Ain Ali

πŸ’» πŸ‘€ 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

Comments
  • ActionSheetStringPicker not working on iPad (only iPhone)

    ActionSheetStringPicker not working on iPad (only iPhone)

    When I call ActionSheetStringPicker on the iPad the screen fades, but the selection won't show up. It just works on my iPhone.

    Here follows the code:

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
        if(textField.tag == 200){
            NSMutableArray *groups = [[NSMutableArray alloc] init];
    
            for (Group *group in [Group sharedUserGroups]) {
                [groups addObject:group.name];
            }
    
            [ActionSheetStringPicker showPickerWithTitle:@"Select a Group"
                                                    rows:groups
                                        initialSelection:0
                                               doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
                                                    textField.text = selectedValue;
                                                    }
                                             cancelBlock:^(ActionSheetStringPicker *picker) {
                                                 NSLog(@"Block Picker Canceled");
                                             }
                                                  origin:self.view];
    

    screen shot 2015-03-26 at 4 59 17 pm screen shot 2015-03-26 at 4 59 55 pm

    bug 
    opened by danielmapar 41
  • No such module 'CoreActionSheetPicker'

    No such module 'CoreActionSheetPicker'

    Hi,

    I installed the ActionSheetPicker via CocaoPods to my project but still getting the error "No such module 'CoreActionSheetPicker'"! I am opening the .xcworkspace file of my project and the examples are compiling fine!

    What am I doing wrong? Any help appreciated!

    question 
    opened by chnbz 38
  • Picker rotating when host view controller fixed to portrait

    Picker rotating when host view controller fixed to portrait

    In my app target settings I've ticked all orientations except for 'Upside Down'. In most view controllers I've limited the orientation to 'Portrait' by using the following code :

    -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }

    This locks the view controller to portrait, but the ActionSheetPicker doesn't respect this and animates itself to landscape when the device is rotated. It also has the effect of taking the status bar with it so this ends up displayed along the long edge of the phone.

    How should I use the control so that it either locks to portrait, or dismisses when the device is rotated? I'm building with Xcode 6/iOS 8 SDK.

    bug help wanted 
    opened by jonathan2708 22
  • On Iphone 4 the ActionSheetStringPicker doesn't work Well

    On Iphone 4 the ActionSheetStringPicker doesn't work Well

    Hi Everyone, when I'm using this picker on iphone 4 (and only on real device) I've this bug. If I try the same code on the Iphone 3,5 inch simulator it works well... What it can be? Thank you so much, best regards! screenshot 2014 06 05 22 48 35

    bug 
    opened by 89moku 21
  • [BUG] - HIGH - Not working on screen rotation + Not working in Landscape

    [BUG] - HIGH - Not working on screen rotation + Not working in Landscape

    Unfortunately I had to find out that the layout is destroyed when rotating under iOS 13. I have already checked it under 2.4.1 (from 2017) and also checked with develop branch with #379 . This error also exists with this version or with the develop branch.

    I created a demo git so that you can easily reproduce it. https://github.com/StefaniOSApps/ActionSheet-Example

    The error is shown in this video. Screen Record

    bug help wanted 
    opened by StefaniOSApps 20
  • not support dark mode on iOS 13

    not support dark mode on iOS 13

    Hello everyone ,

    I updated all my devices and my applications for iOS 13. I work only light content mode for my application. "Actionsheetpicker" does not support if my phone is in dark mode

    can u help with this?

    bug ios13 
    opened by koust 16
  • How to works with ActionStringDoneBlock in Swift?

    How to works with ActionStringDoneBlock in Swift?

    I alwas get this error when i try to write to the "index" variable in this "done" block. I took the code from the Swift Example. A println works inside the block but access to any variable doesn't.

    @IBAction func pickerTouched(sender: UIButton) { var index = 0

        let done: ActionStringDoneBlock = {(picker: ActionSheetStringPicker!, selectedIndex: NSInteger!, selectedValue : AnyObject!) in            
            index = selectedIndex
            return
        }
    
        ActionSheetStringPicker.showPickerWithTitle("Nav Bar From Picker", rows: ["One", "Two", "A lot"], initialSelection: 1, doneBlock: done, cancelBlock: {ActionStringCancelBlock in return }, origin: sender.superview!.superview)
    }
    

    screenshot 2015-02-12 16 30 13

    question 
    opened by manzznam 16
  • Change tint color / font color of Done / Cancel buttons

    Change tint color / font color of Done / Cancel buttons

    I'd like to change the font color of the text on the picker "Cancel" and "Done" buttons. How can they be changed directly.

    My application typically has black menus with white text on the menu.

    I'm calling the following:

    [ActionSheetStringPicker showPickerWithTitle:@"A-Trapezoidal (A-Trap)" rows:self.atrapNamesArray initialSelection:0 target:self successAction:@selector(atrapWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:self.view];
    

    I do have a workaround by calling this line of code, but it causes havoc elsewhere inside my app. i end up putting this in multiple locations and switching the UIColor to do it.

    UIBarButtonItem *barButtonAppearance = [UIBarButtonItem appearance];
    [barButtonAppearance setTintColor:[UIColor blackColor]];
    

    I'd be fine with changing the background color as an alternative.

    enhancement feature-request 
    opened by nneuberger1 16
  • Works on simulator - never starts on device.

    Works on simulator - never starts on device.

    Below is the error log from the iPhone device. I am not sure what its trying to reference? The app works great on the simulator.

    Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000000e7ffdefe Triggered by Thread: 0

    Dyld Error Message: Library not loaded: @rpath/CoreActionSheetPicker.framework/CoreActionSheetPicker Referenced from: /private/var/mobile/Containers/Bundle/Application/6C4ABDB3-9FC6-41C4-A53C-79F083A1740E/NutriLife.app/NutriLife Reason: image not found Dyld Version: 353.6

    Binary Images: 0x1fe20000 - 0x1fe43fff dyld armv7s <8ffd813a380c333bbd4a25e1dbe05715> /usr/lib/dyld

    wontfix unknown 
    opened by mworsnop 15
  • Toolbar buttons don't appear when Actionsheet is fired from an iPad Form Sheet or Page Sheet

    Toolbar buttons don't appear when Actionsheet is fired from an iPad Form Sheet or Page Sheet

    I have a Form Sheet with a button, when I press it the actionsheet toolbar buttons aren't visible although they do still respond to being pressed.

    Here's the actionsheet:

    screenshot 2014 08 22 21 13 21

    This also happens with a page sheet but not full screen.

    This didn't occur with the previous version I was using.

    bug 
    opened by LeoSnek 15
  • iOS 9 support - UIPopoverController deprecated

    iOS 9 support - UIPopoverController deprecated

    Tested on version 1.72, when compiling with Xcode 7.0 beta 6, the following message showed.

    'UIPopoverController' is deprecated: first deprecated in iOS 9.0 - UIPopoverController is deprecated. Popovers are now implemented as UIViewController presentations. Use a modal presentation style of UIModalPresentationPopover and UIPopoverPresentationController.

    enhancement wontfix 
    opened by nationalpaulyip 14
  • Mac Catalyst Warnings

    Mac Catalyst Warnings

    'statusBarStyle' is deprecated: first deprecated in macCatalyst 13.1 - Use the statusBarManager property of the window scene instead.

    'statusBarHidden' is deprecated: first deprecated in macCatalyst 13.1 - Use the statusBarManager property of the window scene instead.

    'beginAnimations:context:' is deprecated: first deprecated in macCatalyst 13.1 - Use the block-based animation API instead

    'setAnimationDuration:' is deprecated: first deprecated in macCatalyst 13.1 - Use the block-based animation API instead

    'setAnimationCurve:' is deprecated: first deprecated in macCatalyst 13.1 - Use the block-based animation API instead

    'commitAnimations' is deprecated: first deprecated in macCatalyst 13.1 - Use the block-based animation API instead

    'showsSelectionIndicator' is deprecated: first deprecated in macCatalyst 13.1 - This property has no effect on iOS 7 and later.

    'UI_USER_INTERFACE_IDIOM' is deprecated: first deprecated in macCatalyst 13.1 - Use -[UIDevice userInterfaceIdiom] directly.

    'keyWindow' is deprecated: first deprecated in macCatalyst 13.1 - Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes

    opened by willm132 1
  • Fix date picker dismissing when tapping on date picker in .inline style

    Fix date picker dismissing when tapping on date picker in .inline style

    Fixes https://github.com/skywinder/ActionSheetPicker-3.0/issues/532 .

    It looks like the issue was introduced in https://github.com/skywinder/ActionSheetPicker-3.0/pull/528, where the tap gesture was moved to the window. The action sheet itself also needs to be exempted from the dismissal tap gesture to work with a datePickerStyle = .inline.

    opened by joeboyscout04 1
  • Fixes issue with SPM imports

    Fixes issue with SPM imports

    Hey,

    The following PR should fix the SPM imports that were requiring a module named <ActionSheetPicker/someheader.h> instead of just referencing the same module.

    opened by mustiikhalil 0
Releases(1.0.10)
Owner
Petr Korolev
Write the code. Change the world.
Petr Korolev
McPicker is a customizable, closure driven UIPickerView drop-in solution with animations that is rotation ready.

McPicker About McPicker is a UIPickerView drop-in solution with animations that is rotation ready. The more string arrays you pass, the more picker co

Kevin McGill 207 Dec 13, 2022
Elegant manager to easily deal with UIPickerView

PickL PickL is an elegant manager to easily deal with UIPickerView. You don't have to implement a logic for UIPickerViewDataSource and UIPickerViewDel

Rosberry 5 Jun 24, 2021
FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

FYPhoto is a photo/video picker and image browser library for iOS written in pure Swift. It is feature-rich and highly customizable to match your App's requirements.

null 10 Dec 11, 2022
Date picker dialog for iOS

DatePickerDialog 4.0 - iOS - Swift DatePickerDialog is an iOS drop-in classe that displays an UIDatePicker within an UIAlertView. Requirements DatePic

Squimer 535 Dec 17, 2022
a picker view shown as a popup for iOS in Objective-C

CZPicker Demo Change Log 3 most recent changes are listed here. Full change logs v0.4.3 - 2016-08-12 Added - (void)czpickerViewWillDisplay:(CZPickerVi

Chen Zeyu 527 Oct 2, 2022
:date: UIDatePicker modally presented with iOS 7 custom transitions.

AIDatePickerController Installation Manually Download and drop /AIDatePickerControllerfolder in your project. Congratulations! Usage // Create a date

Ali Karagoz 90 Sep 23, 2022
An iOS picker view to serve all your "picking" needs

Mandoline The PickerView is a UICollectionView that provides a smooth "picking" interface. In order to get the most out of it, a consuming view contro

Blue Apron 883 Nov 28, 2022
Elegant and Easy-to-Use iOS Swift Date Picker

D2PDatePicker Example To run the example project, clone the repo, and run pod install from the Example directory first. Example Code: Programmatical I

Pradheep Rajendirane 292 Nov 6, 2022
A simple, customizable view for efficiently collecting country information in iOS apps.

CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run

Kizito Nwose 459 Dec 27, 2022
A country picker view controller for iOS

Planet A country picker view controller for iOS. Installation CocoaPods You can use CocoaPods to install Planet by adding it to your Podfile: platform

kWallet 71 Jul 11, 2022
A fully customizable iOS Horizontal PickerView library, written in pure swift

ADDatePicker is Horizontal Date Picker Library written in Swift Requirements Communication Installation Usage Demo Customization Credits License Requi

Abhishek Dave 166 Dec 21, 2022
Multi-picker for iOS and Mac available in SwiftUI

Multi-picker for iOS and Mac available in Swift UI

1amageek 5 Jul 12, 2022
iOS/macOS media picker for importing images and videos in SwiftUI

iOS/macOS media picker for importing images and videos in SwiftUI.

Mobile Development Club 13 Dec 30, 2022
Countries - Simple iOS Project for search on Countries

Do like Countries ??β€β˜ οΈ Simple iOS Project for search on Countries The project c

Amir Ardalan 0 Feb 27, 2022
TextField with DropDown support using UIPickerView

IQDropDownTextField TextField with DropDown support using UIPickerView Installing Install using cocoapods. Add in your Podfile: pod 'IQDropDownTextFie

Mohd Iftekhar Qurashi 301 Jun 29, 2022
Deck is a library that provides a UI to reproduce stacked cards for SwiftUI.

Deck Deck is a library that provides a UI to reproduce stacked cards for SwiftUI. RPReplay_Final1624531727.mov Usage struct Card: View { var data

1amageek 21 Dec 14, 2022
Sample project to reproduce Xcode 13 indexing problems

Xcode 13 indexing regression for Swift static libraries Summary: Currently if you have a project that links a pre-compiled Swift static library (with

AndrΓ© Alves 13 Nov 3, 2022
Steps and files needed to reproduce a CSP bug in Safari Web Extensions

CSP Safari bug repro There appears to be a discrepancy between how Safari handles CSP policies for extension pages compared to how other browsers do s

Brian Birtles 0 Nov 6, 2021
Test project to reproduce a lockup in Vapor

Test project to reproduce a lockup in Vapor The issue was first observed when backing up the SPI database during operation. Running pg_dump would caus

Sven A. Schmidt 1 Dec 30, 2021
πŸ“‘ Actionsheet with navigation features such as the Flipboard App

?? SHEET helps you easily create a wide variety of action sheets with navigation features used in the Flipboard App Installation CocoaPods pod 'Sheet'

ArLupin 322 Nov 28, 2022