a picker view shown as a popup for iOS in Objective-C

Overview

CZPicker

CI Status Version License Platform

Demo

Change Log

3 most recent changes are listed here.

Full change logs

v0.4.3 - 2016-08-12

  • Added - (void)czpickerViewWillDisplay:(CZPickerView *)pickerView;
  • Added - (void)czpickerViewDidDisplay:(CZPickerView *)pickerView;
  • Added - (void)czpickerViewWillDismiss:(CZPickerView *)pickerView;
  • Added - (void)czpickerViewDidDismiss:(CZPickerView *)pickerView;
  • Added - (void)reloadData to reload picker.
  • Added - (void)showInContainer:(id)container.

v0.4.2 - 2016-04-12

  • Improve orientation handler to avoid unnecessary pop up animations.

v0.4.1 - 2016-04-10

  • Remove bundle resources setting in podspec file.

Usage

CZPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CZPicker"

To run the example project, clone the repo, and run pod install from the Example directory first.

Swift

If you are using swift, please refer to swift demo project.

To show the picker, simply adding the following code:

CZPickerView *picker = [[CZPickerView alloc] initWithHeaderTitle:@"Fruits"
                        cancelButtonTitle:@"Cancel"
                        confirmButtonTitle:@"Confirm"];
picker.delegate = self;
picker.dataSource = self;
[picker show];

and implement the dataSource and Delegate methods:

#prama mark - CZPickerViewDataSource

@required
/* number of items for picker */
- (NSInteger)numberOfRowsInPickerView:(CZPickerView *)pickerView;

@optional
/*
 Implement at least one of the following method,
 czpickerView:(CZPickerView *)pickerView
 attributedTitleForRow:(NSInteger)row has higer priority
*/

/* attributed picker item title for each row */
- (NSAttributedString *)czpickerView:(CZPickerView *)pickerView
                            attributedTitleForRow:(NSInteger)row;

/* picker item title for each row */
- (NSString *)czpickerView:(CZPickerView *)pickerView
                            titleForRow:(NSInteger)row;



#prama mark - CZPickerViewDelegate
@optional
/** delegate method for picking one item */
- (void)czpickerView:(CZPickerView *)pickerView
          didConfirmWithItemAtRow:(NSInteger)row;

/** delegate method for picking multiple items,
 implement this method if allowMultipleSelection is YES,
 rows is an array of NSNumbers
 */
- (void)czpickerView:(CZPickerView *)pickerView
          didConfirmWithItemsAtRows:(NSArray *)rows;
/** delegate method for canceling */
- (void)czpickerViewDidClickCancelButton:(CZPickerView *)pickerView;

Customization

There are a lot of things can be customized, change the following properties to customize the picker of your own:

/** whether to show footer (including confirm and cancel buttons), default NO */
@property BOOL needFooterView;

/** whether allow tap background to dismiss the picker, default YES */
@property BOOL tapBackgroundToDismiss;

/** whether allow selection of multiple items/rows, default NO, if this
 property is YES, then footerView will be shown */
@property BOOL allowMultipleSelection;

/** picker header background color */
@property (nonatomic, strong) UIColor *headerBackgroundColor;

/** picker header title color */
@property (nonatomic, strong) UIColor *headerTitleColor;

/** picker cancel button background color */
@property (nonatomic, strong) UIColor *cancelButtonBackgroundColor;

/** picker cancel button normal state color */
@property (nonatomic, strong) UIColor *cancelButtonNormalColor;

/** picker cancel button highlighted state color */
@property (nonatomic, strong) UIColor *cancelButtonHighlightedColor;

/** picker confirm button background color */
@property (nonatomic, strong) UIColor *confirmButtonBackgroundColor;

/** picker confirm button normal state color */
@property (nonatomic, strong) UIColor *confirmButtonNormalColor;

/** picker confirm button highlighted state color */
@property (nonatomic, strong) UIColor *confirmButtonHighlightedColor;

/** picker's animation duration for showing and dismissing*/
@property CGFloat animationDuration;

Author

chenzeyu, [email protected]

License

CZPicker is available under the MIT license. See the LICENSE file for more info.

Credits

CZPicker is created at and supported by Fooyo.sg

Comments
  • Add image to table cell

    Add image to table cell

    Hey Zeyu,

    I am using CZPicker in my application, appreciate it since you make it simple to use. Because I need to present an image for each cell as well, I've added this into your classes ;)

    opened by rxcai 6
  • Add display flexibility

    Add display flexibility

    Currently after the picker is displayed it is very stiff and doesn't expose much or allow itself to be changed. I've added some helper methods to allow for the tableview to be reloaded, for the user to know if the picker is visible on the screen, and to show the picker inside of a subview

    opened by pushchris 4
  • Remember last select row ;)

    Remember last select row ;)

    Hello, thanks for your excellent work. I wanted to know if there is a way to recall the previous active selection. Eg. By calling the "selectRow" Thank You.

    enhancement 
    opened by paoloandrea 4
  • multiple selection not work in swift

    multiple selection not work in swift

    Hi, thanks for your work. I am using Swift 4, and try to use multiple selection.

    However, [self.delegate respondsToSelector:@selector(czpickerView:didConfirmWithItemsAtRows:)] is always false and cannot call function "func czpickerView(pickerView: CZPickerView!, didConfirmWithItemsAtRows rows: [AnyObject]!)"

    Do you know why?

    Thanks.

    opened by ryamashita 3
  • Unable to use didConfirmWithItemsAtRows for selecting multiple items

    Unable to use didConfirmWithItemsAtRows for selecting multiple items

    I want to let use select multiple item in my PickerView.

    func czpickerView(pickerView: CZPickerView!, didConfirmWithItemsAtRows rows: Array!) { }

    If I use delegate method as above, I am getting both warning and error as shown in below image:

    error

    Changing method to following remvoes the warning but error is still there: @objc func czpickerView(pickerView: CZPickerView!, didConfirmWithItemsAtRows rows: Array) { }

    What I'm missing for this method?

    opened by uniruddh 3
  • how to add an optional search bar.!

    how to add an optional search bar.!

    With an optional search bar on top of the the table view, the CZPicker will be optimized for using in large lists. I currently use it with lists having 10-200 items. and It will be awesome if it will be supported in a later version.

    opened by kunalverma25 3
  • Adding delete option

    Adding delete option

    Hi, I am using CZPicker, it is really great component for my App. I was needed to add an option to delete row from the list so i've added it. It would be great if you will add it to the main branch so everybody will be able to use this option :)

    Thanks!

    opened by Applitom 3
  • Orientation Issue

    Orientation Issue

    I found an issue about orientation on Portrait app. I set project configure as Portrait orientation only. But every times I rotate an app. CZPicker view will animate in again.

    Using CZPicker (0.3.2)

    bug 
    opened by wanpaya 3
  • orientation issue

    orientation issue

    There is an issue with the orientation of the picker. To simulate do the following: Open the app in portrait and tap to open the picker. Then rotate the device. You will see that it does not show correctly.

    Thanks for the library.

    bug 
    opened by mythodeia 3
  • Issue with exporting IPA

    Issue with exporting IPA

    [MT] Presenting: Error Domain=IDEFoundationErrorDomain Code=1 "Info.plist of “App.app/Frameworks/CZPicker.framework” specifies a simulator platform for the CFBundleSupportedPlatforms key" UserInfo={NSLocalizedDescription=Info.plist of “App.app/Frameworks/CZPicker.framework” specifies a simulator platform for the CFBundleSupportedPlatforms key}

    opened by ravifullestop 2
  • Pass options to 'preselect'

    Pass options to 'preselect'

    Hi,

    Is there a way to present a modal with certain options already selected by default? If not, how would you go around implementing this? I don't mind putting in the work and making a PR later on.

    opened by aravasio 2
  • For SWİFT

    For SWİFT

    Will you realease your code for Swift ? I am almost new at swift coding and ı don't know how to import objective c code into my swift project. Thank you for your helping

    opened by bakigunes 0
  •  the picker pop up at the top , how can pop up at center

    the picker pop up at the top , how can pop up at center

    I have an issue with when the text field showing the picker at the end of the view controller and my view controller is very tall. the picker is popping up at top of the view controller but the text field at the bottom. Is there any way to pop up the picker at the center of the view controller, not at the top?

    opened by sarakhater 4
  • didChangeItemsAtRows added

    didChangeItemsAtRows added

    usage sample for enum

    func czpickerView(_ pickerView: CZPickerView!, didChangeItemsAtRows rows: [Any]!) {

        if (pickerView == pickerPref) {
            
            var values = [UserPref]()
            
            for row in rows {
                if let row = row as? Int {
                    print(pickerPrefArray[row])
                    values.append(pickerPrefArray[row])
                }
            }
            
            if (values.count>1) {
            
                if (values.contains(.some)) {
                    pickerView.unselectAll()
                    print("You cannot select some with other options")
                }
                
            }
            
        }
    }
    
    opened by canaksoy 0
Owner
Chen Zeyu
Chen Zeyu
A better SwiftUI Picker Use _Picker instead of Picker

BetterPicker A better SwiftUI Picker. Use _Picker instead of Picker. Create styles with _PickerStyle. The is a WIP This library is currently a work-in

Eric Lewis 17 Dec 14, 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
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 simple yet customizable horizontal and vertical picker view

WheelPicker A simple yet customizable horizontal and vertical picker view Features Vertical or Horizontal picker Image or Text data Configure UILabel

Mind Studios 74 Sep 26, 2022
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
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
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
🎯 Swift country and phone code Picker

CountryPicker Picker code Swift 3 / 4 / 5. Example To run the example project, clone the repo, and run pod install from the Example directory first. U

null 207 Dec 22, 2022
MICountryPicker is a country picker controller for iOS8+ with an option to search.

MICountryPicker MICountryPicker is a country picker controller for iOS8+ with an option to search. The list of countries is based on the ISO 3166 coun

Mustafa Ibrahim 90 Mar 27, 2021
A simple, customizable Country picker for picking country or dialing code. 🇮🇳 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧

CountryPicker A simple, customizable Country picker for picking country or dialing code. This library is for country picker used in many app for selec

Suryakant 243 Dec 8, 2022
A drop in single image picker.

PHSingleImagePicker A low memory, single image picker wrapper that provide a significant smaller file size while also preserve high image quality. Int

Phanith NY 0 Nov 6, 2021
React-native-place-picker: Pick any place with single click 🚀

React-native-place-picker: Pick any place with single click ??

b0iq 59 Dec 29, 2022
A SwiftUI implementation of a picker that also allows direct input.

ComboPicker ComboPicker is a SwiftUI view that allows users to input a value by selecting from a predefined set or by typing a custom one. Installatio

Alessio Moiso 5 Sep 13, 2022
LocationPicker - A ready for use and fully customizable location picker for your app

LocationPicker A ready for use and fully customizable location picker for your app. Features Installation Cocoapods Carthage Swift Package Manager Qui

Zhuoran 397 Nov 16, 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
Quickly reproduce the dropdown UIPickerView / ActionSheet functionality on iOS.

ActionSheetPicker-3.0 Important update Now I fixed most of the things and merge PR' (thanks to ). I did much work to support this library from iOS 5.

Petr Korolev 3.4k Dec 21, 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