1

I've created a custom keyboard programmatically. There is no Storyboard. I'd like to add an Accessory View above as per Apple's own keyboard. Can't figure out how to do this in swift inside my Keyboard file within my app.

I tried (row0 is a UIView):

self.view.inputAccessoryView?.addSubview(row0)

Thanks!

1 Answers1

0

You don't do this in a custom keyboard - the inputAccessoryView is something that the app itself (the one controlling the text field you're entering text into) adds above whatever keyboard is in use. If you need more height for your keyboard, you can use this code (copied from Apple's App Extension Programming Guide):

CGFloat _expandedHeight = 500; // this is the height you want your keyboard to be
NSLayoutConstraint *_heightConstraint = 
    [NSLayoutConstraint constraintWithItem: self.view 
                                 attribute: NSLayoutAttributeHeight 
                                 relatedBy: NSLayoutRelationEqual 
                                    toItem: nil 
                                 attribute: NSLayoutAttributeNotAnAttribute 
                                multiplier: 0.0 
                                  constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
Undo
  • 25,519
  • 37
  • 106
  • 129
  • Hello, I am use Your code but not increasing height of customkeyboard. – Kirit Modi Jan 05 '15 at 07:20
  • Then how to activate inputAccessoryView? Using the system keyboard, inputaccessoryview appears to work but with my custom keyboard, i can't see any interface to activate the inputaccessoryview – LKM Aug 06 '16 at 16:40