5

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;
Community
  • 1
  • 1
Paresh Masani
  • 7,474
  • 12
  • 73
  • 139
  • possible duplicate of http://stackoverflow.com/questions/6042060/custom-keyboard-inputview-how-to-change-the-keyboard-size – Krizai Feb 03 '14 at 15:06

1 Answers1

0

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!

msgambel
  • 7,320
  • 4
  • 46
  • 62
  • Yes I am using NIB. View in NIB itself 260x220 and have background color clear. I have another view exactly the same size in the view autosized to left corner. With this settings users can see only left side inputview of 260x220 and rest width (261 to 768) is see through but it doesn't recognise user interaction for that much area which is bad! That's why I want my input view to resize 260x220 and stay in left corner! – Paresh Masani Nov 15 '12 at 19:06
  • Why don't you just get the `inputView` to pass the touches to the parent view on the right side then? – msgambel Nov 16 '12 at 06:17
  • I have main parentview which has left, top, bottom children. Left child needs custom inputview. Bottom child is UITableViewController so I can scroll on bottom-half tableview when I have inputview visible. I can forward touches to my parent but I don't think it will scroll uitableview? Anyway if resizing inputview is not possible then I will go ahead and disable user interaction on top and bottom both when inputview visible which will work for me. – Paresh Masani Nov 16 '12 at 09:20
  • @msgambel is there any way to change the frame (more specifically size) of the view after setting it as the inputView ? I have a feature in my application that should allow users to expand/collapse a custom keyboard but i could not achieve it. – rokridi May 22 '15 at 19:12
  • @rokridi There are 2 ways you could achieve that feature. The first is to have an expand/collapse button that makes the `UITextField` active/in-active, which brings up the custom `inputView`. This should give an expand/collapse feature to your application. Alternatively, you could reset the `inputView` after an animation to expand/collapse the custom view has finished. This would reset the frame, and give you the desired effect. Hope that Helps! – msgambel May 22 '15 at 19:27
  • By expand/collapse i mean i want to change the height of the custom keyboard from 216 to 400 and vice versa. I tried what you have suggested but the frame of the custom keyboard's view remains the same. I am using a UIViewController which i assign its view to the inputView of a UITextView. – rokridi May 22 '15 at 23:42
  • Are you changing the `.frame` view of the custom `inputView`? You can't just change the `subviews`. – msgambel May 23 '15 at 00:08
  • Yes i am changing the frame of the view assigned to the inputView. I do not know what is the solution to this. – rokridi May 25 '15 at 09:57