Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法限制 UIDatePicker 中的日期范围?我知道 maximumdate 和 minimumdate 属性,但我想将可见的最小年份限制为 2010 年。我不希望用户能够看到 2010 年之前的任何年份。有什么想法吗?
我不相信使用 UIDatePicker 是不可能的,但您可以使用自己的 UIPickerView 实现这一点,确保实现 UIPickerViewDelegate 方法,pickerView:didSelectRow:inComponent:以处理糟糕的日期,例如 2 月 30 日(模仿 UIDatePicker 的行为) .
pickerView:didSelectRow:inComponent: