4

I want to change the height of keyboard in XCode 6 Beta 5. I searched code and found that by using NSLayoutConstraint, we can change the height of it but not work for me.

This is my code:

CGFloat _expandedHeight = 500;
NSLayoutConstraint *_heightConstraint =
[NSLayoutConstraint constraintWithItem: self.view
                             attribute: NSLayoutAttributeHeight
                             relatedBy: NSLayoutRelationEqual
                                toItem: nil
                             attribute: NSLayoutAttributeNotAnAttribute
                            multiplier: 0.0
                              constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
Matthew Haugen
  • 12,916
  • 5
  • 38
  • 54
Ikambad
  • 104
  • 5
  • i put this code in **viewDidAppear** and **keypress** methods but also not work for me – Ikambad Aug 21 '14 at 09:58
  • @lkambad , If your using xcode beta 3 or beta 4 i think it doesnt happen. Even i tried but no changes with height . Some are successful with beta 5 and beta 6. – codeIgnitor Aug 21 '14 at 11:17
  • @codeIgnitor i note down that i use xcode 6 beta 5....but not working – Ikambad Aug 21 '14 at 11:21
  • @codeIgnitor there are many other user who facing same problem just visit https://stackoverflow.com/questions/25486802/not-able-to-set-the-height-of-the-custom-keyboard-for-using-any-of-the-version-x#autocomment40547457 – Ikambad Sep 18 '14 at 06:42
  • possible duplicate of [iOS 8 Custom Keyboard: Changing the Height](http://stackoverflow.com/questions/24167909/ios-8-custom-keyboard-changing-the-height) – ljk321 Apr 20 '15 at 23:20

1 Answers1

1

In order for this to work all the views that are added to the UIInputViewController's view need to use layout constraints so you can't add any subviews that use UIViewAutoresizing masks. If you want to use UIViewAutoresizing just add a subview like below then add all of your other views to that view.

UIView *mainView = [[UIView alloc] initWithFrame:self.view.bounds];

[mainView setTranslatesAutoresizingMaskIntoConstraints:NO];

[self.view addSubview:mainView];

NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0];

NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.0];

[self.view addConstraints:@[widthConstraint, heightConstraint]];
coder
  • 11
  • 1