0

我有一个 uipickerview,您可以选择已设置为数组的项目,但我正在努力研究如何将 uilabel 的文本设置为所选选项。

这是我用来创建 uipicker 委托和数据源的代码:

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
    return [treatments count];
}

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

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
      return[[treatments objectAtIndex:row]valueForKey:@"treatmentName"];
}

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

}

我所知道的是它必须在 uipicker didselectrow 函数中完成

提前致谢

4

1 回答 1

2

在下面的方法中设置文本标签

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
      yourLbl.text = [[treatments objectAtIndex:row]valueForKey:@"treatmentName"];
}
于 2013-07-27T12:30:57.727 回答