Leg*_*las 1 iphone xcode objective-c textfield uipickerview
滚动PickerView(或)UIDatePicker之后,我需要将其值显示在TextField上:
滚动时。即使在选择器移动时,文本字段也应自行更新。可能吗 ?
如果拾纸器停止移动并停下来。有一个事件使PickerView停止运行,以便我可以更新textField(在pickerView停止运行时)。
// I do not wish to use the TextFieldDidEndEditing
// I want the textField to update itself when the picker view comes to rest.
Run Code Online (Sandbox Code Playgroud)如果有人可以解决1)和2)将会很有帮助。
(1)不可能。对于(2),可以使用委托方法pickerView:didSelectRow:inComponent。让我知道您是否需要任何帮助。
对于 UIPickerView
(1)实施pickerView:titleForRow:forComponent,
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
// Every time the picker view is rotated, this method will be called to fetch the title.
NSInteger selectedRow = [pickerView selectedRowInComponent:0];
// Get selected row like above and process data and update text field.
[..] // Process the title
return the title.
}
Run Code Online (Sandbox Code Playgroud)
(2)这更加明显。
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// You have the selected row, update the text field.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1432 次 |
| 最近记录: |