Date Picker working differently on 3GS than 3G, touch and iPad
My app hit the app store today. I had a user submit a weird bug. I have a date picker that passes back a date that I store as a string in SQLite. I tested the app on the simulator, a 3G, a itouch, and an iPAD. On all of these, it works as expected. However, on this user's 3GS it adds a day to the date selected in the date picker.
I am not doing any manipulation with the date other than using 开发者_运维知识库an NSDateformatter with NSDateFormatterMediumStyle style to convert to a string to store in the db.
Any ideas why this would work differently on the 3GS?
Have you considered the possibility that the bug is related to the iOS4 upgrade rather than a device specific issue?
I had this same issue but only after updating to iOS4. My formatter is like this:
[aDateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss z"];
and my dates like this:
2009-10-27 7:30:12 -0700
I managed to fix the issue just by moving the date picker mode set before applying the max/min/selected date to the date picker. In my case this:
aDatePicker.datePickerMode = UIDatePickerModeDate;
This sounds like a timezone issue rather than an issue with the 3GS.
I am not sure if this is true with the NSDateformatter (i'll try it out), but if you get description property of the NSDate, you will get a local time (with GMT offset).
If you are persisting these local time strings and then de-persisting them assuming GMT (or if the timezone on the device changed) then the times are going to be wrong. Check what timezone the user is in and try testing with your system timezone set accordingly (Simulator will use the MacOS timezone).
Check that you're setting the NSLocale on any date formatters and date scanners. By default, they use the user's locale, which might be different if they've set it to something other than your locale.
精彩评论