UIDatePicker valueChanged 轮子旋转? [英] UIDatePicker valueChanged as wheels spin?

查看:17
本文介绍了UIDatePicker valueChanged 轮子旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 UIDatePicker 用日期更新 UILabel,但我注意到 valueChanged 事件仅在车轮停止旋转.

I’m using a UIDatePicker to update UILabel with a date, but I’m noticing that the valueChanged event is only called when the wheels stop spinning.

理想情况下,如果用户轻弹一列,我希望标签中的日期随着轮子的旋转不断更新,以获得实时反馈.

Ideally if the user flicks a column, I’d like the date in the label to update continuously as the wheel spins, for a realtime sense of feedback.

这可能吗?

推荐答案

这是一个极端的解决方法,但是...

This is an extreme workaround, but...

如果您使用 UIPickerView 而不是 UIDatePicker(当然,这将需要重新实现大部分 DatePicker),您可以在 pickerView:viewForRow:forComponent:reusingView: 委托方法中检测轮子旋转.如果行数超过了一次可以显示的行数,则每次滚轮移动时都会调用此方法.

If you use a UIPickerView instead of a UIDatePicker (which, granted, would entail re-implementing most of the DatePicker), you can detect the wheel spinning in the pickerView:viewForRow:forComponent:reusingView: delegate method. If there are more rows than can be displayed at once, this will be called every time the wheel moves.

这篇关于UIDatePicker valueChanged 轮子旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆