问题
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