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