【问题标题】:Is there anyway to hide the 24hrs format in UIDatePicker无论如何要在 UIDatePicker 中隐藏 24 小时格式
【发布时间】:2016-11-15 12:36:52
【问题描述】:

我正在使用UIDatePicker 进行时间格式的应用程序。它以 12 小时格式工作,如果我将 iPhone 日期/时间更改为 24 小时格式,我只需要显示 12 小时格式,而不是 24 小时格式。

是否有禁用 24 小时格式的方法?

【问题讨论】:

标签: ios objective-c uidatepickermodetime


【解决方案1】:

将此代码用于 12 小时格式

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"US"];
[self.datePicker setLocale:locale];

将此代码用于 24 小时格式

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"NL"];
[self.datePicker setLocale:locale];

【讨论】:

  • @user2384583 这将始终显示 12 小时格式。你试过了吗?
  • 如果我将 iphone 日期/时间更改为 24 小时格式,它不会显示 12 小时格式。
  • @user2384583 你的厕所 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-01-17
  • 2023-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多