Code Monkey home page Code Monkey logo

lapickerview's Introduction

LAPickerView

Introduction

LAPickerView is an horizontal spinning-wheel picker control view for iOS.

It is similar to UIPickerView, but the user interface provided consists of columns instead of rows. It also follows the same semantics used for the data source and delegate methods. Please read the Overview section for more details about usage.

Requirements

  • iOS 5.1 or later
  • Suported devices: iPhone/iPad (*)

How to use LAPickerView in your project

CocoaPods

  1. Create or edit an existing text file named Podfile in your Xcode project directory:
platform :ios, '5.1'

pod "LAPickerView", '~> 0.2.0'
  1. Install LAPickerView in your project:
$ pod install
  1. Open the Xcode workspace instead of the project file when building your project:
$ open YourProject.xcworkspace
  1. Use LAPickerView in your project:
#import <LAPickerView/LAPickerView.h>

Framework

  1. Import the LAPickerView.framework to your project
  2. Add '-ObjC' to Other Linker Flag in Build Settings target section (in order to load Objective-C class categories)
  3. Add LAPickerView.framework to Link Binary with Libraries in Build Phases target section

You also need to add the following frameworks to your project:

  • QuartzCore.framework
  • CoreGraphics.framework
  • AudioToolbox.framework

Overview Tutorial

  1. Add the LAPickerView to an existing UIView (ie. inside UIViewController's viewDidLoad method).
LAPickerView * pickerView = [[LAPickerView alloc] initWithFrame:self.view.frame];
pickerView.dataSource = self; // LAPickerViewDataSource protocol
pickerView.delegate = self;   // LAPickerViewDelegate protocol
[self.view addSubview:pickerView];
  1. Implement the LAPickerViewDataSource protocol:
- (NSInteger)numberOfComponentsInPickerView:(LAPickerView *)pickerView
{
    // return the number of components needed
}

- (NSInteger)pickerView:(LAPickerView *)pickerView numberOfColumnsInComponent:(NSInteger)component
{
    // return the number of columns for each component
}
  1. Implement the LAPickerViewDelegate protocol:
- (NSString *)pickerView:(LAPickerView *)pickerView titleForColumn:(NSInteger)column forComponent:(NSInteger)component
{
    // return the title for the specific column-component pair
}

- (void)pickerView:(LAPickerView *)pickerView didSelectColumn:(NSInteger)column inComponent:(NSInteger)component
{
    // called when a new, different column is selected following a user touch-based input
}
  1. Additionally you can change the selected column position to left, center or right.

Selection Alignment Options

pickerView.selectionAlignment = LAPickerSelectionAlignmentLeft; // Change selected column position to left

Examples

LAPickerViewOverview

The LAPickerViewOverview is a single-view example showing the LAPickerView and UIPickerView side-by-side. The selection is linked, so changing the selected column in the LAPickerView will trigger the UIPickerView to change to the corresponding row.

LAPickerView Overview Example Screenshot

Roadmap

  • Improve layout and autoresize constraints
  • Fix click sound loudness
  • Fix click sound while scrolling
  • Improve selected to unselected state animation
  • Implement 3D transform similar to UIPickerView

lapickerview's People

Contributors

luislaugga avatar

Watchers

Antonio Agudo avatar James Cloos 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.