Coder Social home page Coder Social logo

nelsonnan / actionsheetpicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timcinel/actionsheetpicker

0.0 2.0 0.0 2.33 MB

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

License: BSD 3-Clause "New" or "Revised" License

actionsheetpicker's Introduction

Attention:

This repo is outdated. I try to resolve a lot of pull requests and issues in this repo by time, but new updates will be appeared in https://github.com/skywinder/ActionSheetPicker-3.0. I forked from this repo and implement a bunch of fixes.

You can find new version of ActionSheetPicker here: ActionSheetPicker-3.0.

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

ActionSheetCustomPicker Customization

ActionSheetCustomPicker provides the following delegate function that can be used for customization:

- (void)actionSheetPicker:(AbstractActionSheetPicker *)actionSheetPicker configurePickerView:(UIPickerView *)pickerView;

This method is called right before actionSheetPicker is presented and it can be used to customize the appearance and properties of the actionSheetPicker and the pickerView associated with it.

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, crashfix, update for iOS7, new pickers)

Nikos Mouzakitis

Creator

Tim Cinel

@TimCinel

timcinel.com/

actionsheetpicker's People

Contributors

skywinder avatar timcinel avatar delackner avatar johnnyg avatar grgcombs avatar nimuzak avatar stupergenius avatar ecordell avatar mau04 avatar markrickert avatar 0xmark avatar jkrzemie avatar brettg avatar typeoneerror avatar carlostse avatar greenwoodcm avatar eloe avatar gituser03 avatar jaseelder avatar jparise avatar elwerene avatar ronakjangir47 avatar

Watchers

James Cloos avatar nelson_nan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.