我有一个UIPickerView。它工作正常。但是在滚动行之前它不会选择任何行。
这是我的代码。
selectProArray = [[NSMutableArray alloc]initWithObjects:@"ABC",
@"DEF",
@"IJK",
nil];
selectPROPicker = [[UIPickerView alloc]init];
selectPROPicker.backgroundColor = [UIColor colorWithRed:209.0/255.0
green:213.0/255.0
blue:219.0/255.0
alpha:1];
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
selectedPickerRow=[selectProArray objectAtIndex:row];
NSLog(@"SelectedRow=%@",selectedPickerRow);
rowID = row;
[selectField resignFirstResponder];
}
答案 0 :(得分:2)
在pickerView中选择一行
picker= [[UIPickerView alloc]init];
[picker selectRow:0 inComponent:0 animated:NO];
更新textField中的值,为ur textField
设置委托- (void)textFieldDidBeginEditing:(UITextField *)textField
{
textField.text = [self.yourArrayName objectAtIndex:[self.yourPickerName selectedRowInComponent:0]];//component index may differ for u
}