只要我滚动PickerView(或)UIDatePicker,我就需要在TextField:上显示值
-
滚动时。即使拾取器在移动,文本字段也应该更新自己。有可能吗?
-
关于Picker停止移动并静止的事件。是否有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.
如果有人能解决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.
}
(2) 这一点更为明显。
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// You have the selected row, update the text field.
}
对于第一个问题,这在默认控件中是不可能的,但没有什么可以阻止您编写自己的控件并使用touchesMoved
等模拟效果。