UIPickerView 在 TextField 上实时更新
一旦我滚动 PickerView(或)UIDatePicker,我就需要将值显示在 TextField 上:
滚动时。即使选择器移动,文本字段也应该自行更新。这可能吗?
当拾取器停止移动并停止时。是否有一个让 PickerView 停止的事件,以便我可以更新文本字段(一旦 pickerView 停止)。
// 我不想使用 TextFieldDidEndEditing // 我希望文本字段在选择器视图停止时自动更新。
如果有人能解决 1) 和 2),那将会很有帮助
As soon as I scroll the PickerView (or) UIDatePicker, I need the value to get displayed on a TextField :
While Scrolling. Even when the picker is moving the text field should update itself. Is it possible ?
On the event that the Picker stops moving and comes to rest. Is there an event for the PickerView to come to rest so that I could update the textField (as soon as the pickerView comes to rest).
// I do not wish to use the TextFieldDidEndEditing // I want the textField to update itself when the picker view comes to rest.
It would be helpful if anyone could solve 1) and 2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
(1) 可能不可能。对于(2),您可以使用委托方法
pickerView:didSelectRow:inComponent
。如果您需要任何帮助,请告诉我。对于
UIPickerView
(1)实现
pickerView:titleForRow:forComponent
,(2)这样就比较明显了。
(1) might not be possible. For (2), you can use the delegate method
pickerView:didSelectRow:inComponent
. Let me know if you need any help with this.For
UIPickerView
(1) Implement
pickerView:titleForRow:forComponent
,(2) This is more obvious.
对于第一个问题,这对于默认控件是不可能的,但是没有什么可以阻止您编写自己的控件并使用
touchesMoved
等来模拟效果...For the first question, this isn't possible with the default control however there is nothing to stop you writing your own and simulate the effect using
touchesMoved
etc...