I\'d to like to add a word selection view similar to the above in an iOS 8 cus
You want to change the size and contents of input accessory view based on input. Not the frame of the keyboard (input view). The areas you marked with red rectangles are input accessory views in two different states.
UIKit
posts keyboard related notifications.
UIKeyboardWillShowNotification
, UIKeyboardDidShowNotification
, UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
The object listening for these notifications can get geometry information related to the input view - like height of the keyboard - to adjust the edited views.
To change the input accessory view based on input you have to first observe changes in its contents. You can do it either by implementing the UITextFieldDelegate
's textField:shouldChangeCharactersInRange:replacementString:
method or listening for UITextFieldTextDidChangeNotification
.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleTextFieldDidChangeNotification:)
name:UITextFieldTextDidChangeNotification
object:_textFieldInInputAccessoryView];
The key is to change the input accessory view contents and size when the change in the text field occurs. UIKit attaches the input accessory view to the top of the input view (keyboard). What you have to do is to update the frame of the input accessory view if you want to add an extra line with controls below the text field.
- (void)handleTextFieldDidChangeNotification:(NSNotification *)notification
{
// Update the contents/frame of the input accessory view.
// Reload the input views.
[_yourTextField reloadInputViews];
}
Based on Text Programming Guide for iOS - Custom Views for Data Input
It IS possible to change the size of the keyboard in the current iOS 8
Taken verbatim from the documentation: "In iOS 8.0, you can adjust a custom keyboard’s height any time after its primary view initially draws on screen."
To resize your custom keyboard, add a simple layout constraint.
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];
For more information look at Apple's prerelease documentation here!
You can not use the custom keyboard APIs in iOS 8 to extend the keyboard past its default frame. I know this from asking an Apple engineer this question at WWDC this year.