UIDatePicker does not update the 'Today' f

2019-07-28 07:17发布

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?

2条回答
何必那么认真
2楼-- · 2019-07-28 07:44

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

查看更多
一夜七次
3楼-- · 2019-07-28 07:46

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

查看更多
登录 后发表回答