【问题标题】:Custom DatePicker-iOS自定义 DatePicker-iOS
【发布时间】:2012-10-10 07:56:40
【问题描述】:

我正在从服务器获取我的 JSON 数据,服务器从放置在不同位置的传感器获取数据,收集上午 6 点到晚上 10 点之间的信息。我实现了 datepicker 来选择用户希望看到的任何特定时间。但是我想排除晚上 10 点到早上 6 点?我想以用户无法选择晚上 10 点到早上 6 点之间的任何时间的方式设计我的日期选择器。有没有办法实现这个目标?

【问题讨论】:

    标签: ios datepicker


    【解决方案1】:

    您需要使用UIPickerView,将 4 个段作为日期选择器并通过数组填充它们

    因为UIDatePicker 不继承自UIPickerView (which it says in the last sentence of the "Overview" in the Apple documentation which I linked for you)。

    UIPickerView 使用数据源。

    UIDatePicker 有一个内置的数据源,开发者无法触及

    因此,只需将自定义数据转储到 4 分段正常选择器视图即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      相关资源
      最近更新 更多