iOS9:带有datePickerMode为UIDatePickerModeTime的UIDatePicker仅显示小时,没有分钟 [英] iOS9: UIDatePicker with datePickerMode of UIDatePickerModeTime only shows Hours, and no Minutes

查看:509
本文介绍了iOS9:带有datePickerMode为UIDatePickerModeTime的UIDatePicker仅显示小时,没有分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Xcode beta 7与iOS9模拟器一起使用. 在datePickerMode为UIDatePickerModeTime的情况下使用UIDatePicker仅显示小时,而不显示分钟.

I'm using Xcode beta 7 with the iOS9 simulator. Using a UIDatePicker with a datePickerMode of UIDatePickerModeTime only shows Hours, and not minutes.

查看屏幕截图:

在iOS 7和8上,显然它可以按预期工作,并同时显示小时和分钟.截图:

On iOS 7 and 8, obviously it works as expected, and shows both Hours and Minutes. Screenshot:

我真的不想重新发明轮子,也不用动我自己的时间选择器.关于为什么会发生这种情况以及如何解决的任何想法?我在Google上找不到任何东西.

I really do not want to reinvent the wheel and roll my own time picker. Any ideas on why this might be happening and how to fix? I can't find anything on google.

谢谢, 亚历克斯

推荐答案

在iOS 9发行说明中找到了有关此问题的有用描述-似乎我应该更仔细地阅读这些内容.

Found a useful description of this problem in the iOS 9 release notes - seems I should be reading these more carefully.

UIPickerView和UIDatePicker现在可调整大小和自适应-以前,即使您尝试调整它们的大小,这些视图也将强制使用默认大小.现在,这些视图在所有设备上的默认宽度均为320点,而不是在iPhone上的宽度. 在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发行说明

对于我来说,我要做的就是删除UIDatePicker上的所有约束,然后重置为建议的约束".重建,现在一切都很好.

In my case all I had to do was remove all constraints on the UIDatePicker and then "Reset to Suggested Constraints". Rebuild and now all is well.

这篇关于iOS9:带有datePickerMode为UIDatePickerModeTime的UIDatePicker仅显示小时,没有分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆