[英]UIPickerView set selected
I have a uipickerview that you can select items that have been set into an array but I am struggling to work out how to set the text of a uilabel to the selected option. 我有一个uipickerview,您可以选择已设置为数组的项目,但我正在努力研究如何将uilabel的文本设置为所选选项。
Here is the code that I am using to create the uipicker delegate and datasource: 这是我用来创建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 {
}
All I know is that it has to be done in the uipicker didselectrow function 我所知道的是,它必须在uipicker didselectrow函数中完成
Thanks in advance 提前致谢
set text label in below method 在下面的方法中设置文本标签
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
yourLbl.text = [[treatments objectAtIndex:row]valueForKey:@"treatmentName"];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.