我有一个填充了 NSarray 的 UIPicker。这会将 发送row selected
到文本字段。我想知道如何更改我的选择器中行的名称。抱歉,如果不清楚我很难清楚地解释我的意思。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
arrStatus = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", @"D", nil];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//One column
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent: (NSInteger)component
{
//set number of rows
return arrStatus.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
//set item per row
return [arrStatus objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSInteger selectedRow = [result selectedRowInComponent:0];
text1.text = [arrStatus objectAtIndex:selectedRow];
}