简体   繁体   English

iOS 7:设置为UIDatePicker时,UITextField inputView问题

[英]iOS 7 : UITextField inputView issue when set to UIDatePicker

I have set UIDatePicker as TextField 's inputView. 我已经将UIDatePicker设置为TextField的inputView。 When TextField becomes firstResponder the first time, UIDatePicker 's height is smaller than standard height as shown below : TextField首次成为firstResponder时, UIDatePicker的高度小于标准高度,如下所示:

在此处输入图片说明

Then after any time TextField becomes firstResponder , UIDatePicker 's height is correct as shown below : 然后,在任何时候TextField成为firstResponderUIDatePicker的高度都是正确的,如下所示:

在此处输入图片说明

This issue is not there when I run app on iOS 6 simulator, but only there when run on iOS 7. 当我在iOS 6模拟器上运行应用程序时,不会出现此问题,而只有在iOS 7上运行时才存在。

Any idea why is this? 知道为什么吗? Can it be related to auto layout? 它可以与自动布局相关吗?

I had added UIDatePicker in storyboard. 我已经在情节UIDatePicker中添加了UIDatePicker Now, I have solved the issue by creating UIDatePicker through code and setting it as inputView. 现在,我通过代码创建UIDatePicker并将其设置为inputView来解决了该问题。 I am still looking for an answer that explains the reason why it did not work with storyboard. 我仍在寻找一个答案,以解释为什么它无法与情节提要一起使用的原因。 I will change accepted answer if I get any. 如果有,我将更改接受的答案。

I think it's a "spring issue"... I've solved with this settings: 我认为这是一个“春季问题” ...我已经通过以下设置解决了:

在此处输入图片说明

Take a look at the Autoresizings... 看看自动调整大小...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM