How can I get text on UIPickerView?
If I use a UIPickerView with custom View(3 components) .How could I get each text on开发者_运维百科 UIPickerView from each selectedRow??
THANKS...
You can use picker's delegate method
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(component==0)
{
int i=row; //here i returns the row selected by you in picker component 0
}
else if(component==1)
{
int j=row; //here j returns the row selected by you in picker component 1
}
else if(component==2)
{
int k=row; //here k returns the row selected by you in picker component 2
}
}
It depends on how you decide to place the text into the components.
For example, if you use myArray
:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSLog(@"%@",[myArray objectAtIndex:row]);
}
精彩评论