iOS:自定义UITextField的inputView大小 [英] iOS: Customise UITextField's inputView size
问题描述
我需要自定义 UITextField的
inputView
的大小。我分配给 inputView
的自定义视图已经是 260x220
的大小,但仍然 inputView
显示为260x768( Portrait
)和260x1024( Landscap
)。我尝试更改 inputView的
Frame
,但仍然没有变化。无论如何我可以修改 UITextField的
inputView
Frame
以便它只占据底部屏幕的某个空间?
I need to customise the size of UITextField's
inputView
. My custom view that is assigned to inputView
is already a size of 260x220
but still inputView
appears as 260x768(Portrait
) and 260x1024(Landscap
). I tried changing inputView's
Frame
but still no change. Is there anyway I can modified UITextField's
inputView
Frame
so that it only occupies certain space in bottom screen?
textField.inputView = numPadViewController.view;
[textField.inputView setFrame:CGRectMake(0, 0, 260, 220)];
来自这个,我也尝试了以下,但没有工作!
From this, I tried following as well and didn't work!
numPadViewController.view.autoresizingMask = UIViewAutoresizingNone;
textField.inputView = numPadViewController.view;
推荐答案
你在使用笔尖吗?确保笔尖中的框架设置正确。此外,您无法设置 inputView
的框架。您只能设置视图
的框架,它将是您设置的 inputView
BEFORE 它作为 inputView
。我需要查看更多代码。
Are you using a nib? Make sure that the frame in the nib is set properly. Also, you can't set the frame of the inputView
. You can only set the frame of the view
that will be the inputView
BEFORE you set it as the inputView
. I'd need to see more code otherwise.
此外,最好让 inputView
拥有屏幕宽度相同(768肖像,1024风景)。您仍然可以将视图居中,并且两侧只有透明空间。希望有帮助!
Also, it might be better to make the inputView
have the same width of the screen (768 portrait, 1024 landscape). You could still centre your view, and just have transparent space on the sides. Hope that Helps!
这篇关于iOS:自定义UITextField的inputView大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!