iOS: Customise UITextField's inputView size

ぐ巨炮叔叔 提交于 2019-12-10 14:54:54

问题


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)];

[EDIT]

From this, I tried following as well and didn't work!

numPadViewController.view.autoresizingMask = UIViewAutoresizingNone;
textField.inputView = numPadViewController.view;

回答1:


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.

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!



来源:https://stackoverflow.com/questions/13394564/ios-customise-uitextfields-inputview-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!