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