UIDatePicker does not update the 'Today' f

2019-07-28 07:36发布

问题:

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?

回答1:

The UIDatePicker shows the default value from your Interface Builder setting. I added UIDatePicker in viewDidLoad{} but not in Interface Builder, it works well.



回答2:

As a workaround for this bug you might catch the UIApplicationWillEnterForegroundNotification and dump and recreate the table cells to get a correct 'today' flag.