我在 iOS9 模拟器上使用 Xcode beta 7。
使用带有 UIDatePickerModeTime 的 datePickerMode 的 UIDatePicker 只显示小时,而不是分钟。
看截图:
在 iOS 7 和 8 上,显然它按预期工作,并显示小时和分钟。截屏:
我真的不想重新发明轮子并滚动我自己的时间选择器。关于为什么会发生这种情况以及如何解决的任何想法?我在谷歌上找不到任何东西。
谢谢,
亚历克斯
最佳答案
在 iOS 9 发行说明中找到了有关此问题的有用描述 - 似乎我应该更仔细地阅读这些内容。
UIPickerView and UIDatePicker are now resizable and adaptive—previously, these views would enforce a default size even if you attempted to resize them. These views also now default to a width of 320 points on all devices, instead of to the device width on iPhone. Interfaces that rely on the old enforcement of the default size will likely look wrong when compiled for iOS 9. Any problems encountered can be resolved by fully constraining or sizing picker views to the desired size instead of relying on implicit behavior.
iOS 9 Release Notes
就我而言,我所要做的就是删除 UIDatePicker 上的所有约束,然后“重置为建议的约束”。重建,现在一切都很好。
关于xcode - iOS9:UIDatePicker 和 UIDatePickerModeTime 的 datePickerMode 只显示小时,没有分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31709525/