Bug 34739 - UIDatePicker Date property wrong date
Summary: UIDatePicker Date property wrong date
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-10-09 18:23 UTC by dj_technohead
Modified: 2016-06-09 13:54 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Jan 17 was selected in UIDatePicker, but querying it in the immediate window returns Nov 17 (814.39 KB, image/png)
2015-10-09 18:23 UTC, dj_technohead

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description dj_technohead 2015-10-09 18:23:13 UTC
Created attachment 13266 [details]
Jan 17 was selected in UIDatePicker, but querying it in the immediate window returns Nov 17

I have a UIDatePicker that is presented to the user as a UITextField's InputView. The same UITextField also has an InputAccessoryView that is a toolbar with the buttons Cancel and Done. When the user taps on the UITextField, the UIDatePicker is presented, allowing the user to select a date and then they can press the Done button. This causes the UITextField's text to be updated with the selected date.

This appears to work fine, but every once in a while, the user may select a new date press return, but the UITextField is still showing the previous date. When I examined this in the debugger, what I found was that even though the UIDatePicker was visibly showing the new date, when the code queries the UIDatePicker.Date property, it is returning a different (previous) date. I've attached a screenshot that shows this (Jan 17 was selected in the UIDatePicker, the Done button was pressed, triggering my breakpoint, and when I query the UIDatePicker in the immediate window, it returns Nov 17 2015). 

I haven't found an easy way to repro this, as it appears to happen somewhat randomly.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-10-13 05:40:13 UTC
We're just a thin wrapper around the iOS API, so I'm not quite sure this is really a bug in Xamarin.iOS (as opposed to a bug in iOS or even your own code).

We can look at it, but we'd really need some sort of test case to reproduce it ourselves.

Although there are a few questions that might narrow it down:

* Does it happen on simulator only, or on device as well?
* Does it happen on older versions of iOS as well?
* Can you reproduce the same behavior with a different UI layout? Trying to make things simpler is usually a great way to find out exactly where the problem is.
Comment 2 dj_technohead 2015-10-13 20:08:33 UTC
Thanks Rolf, that's what I thought. I've only tested for it on the simulator. Unfortunately it's hard to repro, I've not found a consistent pattern in its behavior. Was hoping that might have triggered an "aha" on your end.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-10-14 04:32:21 UTC
One thing I noticed is that you're ensuring you're on the main thread. Is the value still wrong if you print it out inside the "Done" button event handler itself?
Comment 4 Sebastien Pouliot 2016-06-09 13:54:06 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!