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.
- iOS 5.1 or later
- Suported devices: iPhone/iPad (*)
- Create or edit an existing text file named Podfile in your Xcode project directory:
platform :ios, '5.1'
pod "LAPickerView", '~> 0.2.0'
- Install LAPickerView in your project:
$ pod install
- Open the Xcode workspace instead of the project file when building your project:
$ open YourProject.xcworkspace
- Use LAPickerView in your project:
#import <LAPickerView/LAPickerView.h>
- Import the LAPickerView.framework to your project
- Add '-ObjC' to Other Linker Flag in Build Settings target section (in order to load Objective-C class categories)
- 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
- 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];
- 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
}
- 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
}
- Additionally you can change the selected column position to left, center or right.
pickerView.selectionAlignment = LAPickerSelectionAlignmentLeft; // Change selected column position to left
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.
- 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