UIDatePicker 更改事件不会在第一次旋转 Swift 时触发 [英] UIDatePicker change event not firing on first spin Swift

查看:26
本文介绍了UIDatePicker 更改事件不会在第一次旋转 Swift 时触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在用户更新 UIDatePicker(倒数计时器)时更新标签.但是,它仅在第一次旋转后更新它.第一次旋转不会改变标签值.我试图在主队列上执行 UI 更新但无济于事.

I am trying to update a label when the UIDatePicker (Count Down Timer) is updated by the user. However, it only updates it after the first spin. The first spin does not change the label value. I have attempted to perform the UI update on the main queue to no avail.

推荐答案

这是一个众所周知且长期存在的错误.如果您仔细观察 Apple 使用倒计时日期选择器的项目(如时钟应用程序的 Timer 部分),他们从不尝试响应旋转选择器的动作;用户必须点击一个按钮,然后读取选择器的值.我建议你设计你的界面类似.

This is a well-known and long-standing bug. If you look closely at Apple's projects that use a count down date picker (like the Timer part of the Clock app), they never try to respond to the action of spinning the picker; the user has to tap a button which then reads the value of the picker. I suggest you design your interface similarly.

这篇关于UIDatePicker 更改事件不会在第一次旋转 Swift 时触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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