用户定义的选择器视图,在其中显示12位数字

时间:2015-09-01 07:43:32

标签: ios objective-c xcode6

我想使用选择器视图显示12位数字,数字是动态的,它必须是轻型航班时刻表显示。数字将会越来越多,我想通过选择器来实现。因为我是IOS的新手需要你的帮助。谢谢

2 个答案:

答案 0 :(得分:0)

#import "DetailViewController.h"

@interface DetailViewController ()<UIPickerViewDataSource,UIPickerViewDelegate>

@end

@implementation DetailViewController

- (void)viewDidLoad {
[super viewDidLoad];

UIPickerView *pickerview = [[UIPickerView alloc]init];
pickerview.delegate = self;
pickerview.dataSource = self;
[self.view addSubview:pickerview];
}

- (void)pickerView:(UIPickerView *)pV didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return 12;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{

NSNumber *digit = @(row);
return [digit stringValue];
}

@end

答案 1 :(得分:-1)

您可以使用Simple Library然后添加Digits数组。

这里有很少的简单库,尝试一次。

  

CPPickerView

     

ActionSheetPicker-3.0

     

AKPickerView