LAPickerView 是一个用于 iOS 的水平旋转盘选择控件视图。
它与 UIPickerView 相似,但提供的用户界面由列而不是行组成。它还遵循相同的数据源和代理方法语义。请阅读“概览”部分以了解更多有关使用方法的信息。
您还需要将以下框架添加到您的项目中
LAPickerView * pickerView = [[LAPickerView alloc] initWithFrame:self.view.frame];
pickerView.dataSource = self; // LAPickerViewDataSource protocol
pickerView.delegate = self; // LAPickerViewDelegate protocol
[self.view addSubview:pickerView];
- (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
}
- (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
}
pickerView.selectionAlignment = LAPickerSelectionAlignmentLeft; // Change selected column position to left
LAPickerView概览 是一个单视图示例,展示了 LAPickerView 和 UIPickerView 并排。选择是链接的,因此更改 LAPickerView 中的选定列将触发 UIPickerView 更改为相应的行。