日期选择器在 3GS 上的工作方式与 3G、触摸屏和 iPad 上的工作方式不同

发布于 2024-09-08 17:32:36 字数 282 浏览 1 评论 0原文

我的应用程序今天登陆了应用程序商店。我让一个用户提交了一个奇怪的错误。我有一个日期选择器,它传回我在 SQLite 中存储为字符串的日期。我在模拟器、3G、itouch 和 iPAD 上测试了该应用程序。在所有这些方面,它都按预期工作。然而,在该用户的 3GS 上,它会向日期选择器中选择的日期添加一天。

除了使用具有 NSDateFormatterMediumStyle 样式的 NSDateformatter 转换为字符串以存储在数据库中之外,我没有对日期进行任何操作。

你知道为什么这在 3GS 上会有所不同吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

給妳壹絲溫柔 2024-09-15 17:32:36

您是否考虑过该错误与 iOS4 升级有关而不是设备特定问题的可能性?

我也遇到了同样的问题,但只是在更新到 iOS4 后才出现。我的格式化程序是这样的:

[日期格式化程序
setDateFormat:@"yyyy-MM-dd HH:mm:ss
z"];

我的日期是这样的:

2009-10-27 7:30:12 -0700

我只需将最大/最小/选定日期应用到日期选择器之前设置的日期选择器模式移动即可解决此问题。就我而言:

aDatePicker.datePickerMode = UIDatePickerModeDate;

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;

雨轻弹 2024-09-15 17:32:36

这听起来像是时区问题,而不是 3GS 的问题。

我不确定 NSDateformatter 是否是这样(我会尝试一下),但是如果您获得 NSDate 的描述属性,您将获得当地时间(带有 GMT 偏移量)。

如果您保留这些本地时间字符串,然后假设 GMT(或者设备上的时区发生更改)取消保留它们,那么时间将是错误的。检查用户所在的时区,并尝试使用相应的系统时区设置进行测试(模拟器将使用 MacOS 时区)。

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).

薯片软お妹 2024-09-15 17:32:36

检查您是否在任何日期格式化程序和日期扫描仪上设置 NSLocale。默认情况下,他们使用用户的区域设置,如果他们将其设置为除您的区域设置之外的其他设置,则可能会有所不同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文