UIDatePicker 不更新“今天”日期提前时标记
我在 UIBuilder 中创建了一个 UIDatepicker,并在应用程序首次加载时实例化一次。首次呈现时,日期选择器会使用“今天”一词正确标记今天的日期。在 iOS 4 上,如果我将应用程序关闭到后台,并在一天后重新激活它,日期会提前,但昨天的日期仍然标记为“今天”。显式更新控件日期没有效果。看起来该控件在创建时仅确定“今天”一次。
我尝试过调用 init 来就地重新初始化它,但无法使其工作。
我错过了什么吗?
I have a UIDatepicker created in UIBuilder and instantiated once when the app first loads. When first presented, the datepicker correctly flags today's date with the word 'Today'. On IOS 4, if I dismiss the app to the background, and reactivate it a day later, the date has advanced, but yesterdays date is still flagged as 'Today'. Explicitly updating the controls date has no effect. It looks like the control determines 'Today' only once, when created.
I've tried calling init to re-initialise it in-situ, but can't get that to work.
Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为此错误的解决方法,您可能会捕获 UIApplicationWillEnterForegroundNotification 并转储并重新创建表格单元格以获得正确的“今天”标志。
As a workaround for this bug you might catch the UIApplicationWillEnterForegroundNotification and dump and recreate the table cells to get a correct 'today' flag.
您可以使用 Interface Builder 中的 UIDatePicker。但是当你返回应用程序时,你需要执行
[datePicker sizeToFit];
它将更新“今天”单元格。
You can use UIDatePicker from Interface Builder. But when you return to the app you need to execute
[datePicker sizeToFit];
and it will updates "Today" cell.
UIDatePicker 显示 Interface Builder 设置中的默认值。我在 viewDidLoad{} 中添加了 UIDatePicker,但没有在 Interface Builder 中添加,它运行良好。
The UIDatePicker shows the default value from your Interface Builder setting. I added UIDatePicker in viewDidLoad{} but not in Interface Builder, it works well.