I am trying to resize the UITextView
when the keyboard is open.
in order to give my UITextView
a new size ( so that it doesn't become shadowed by the keyboard) I make the following calculation
firstResult = UITextView bottom coordinate - keyboard top coordinate
firstResult
should now have the size of the shadowed UITextView frame
then i do textView.frame.size.height -= firstResult
which now should have a new size that would not be shadowed by the keyboard.
The problem with the code as it stands out is that there is always part of the UIView that is hidden behind the keyboard.
Could anyone point out what's wrong with my calculations so that the new size is always right? or any other way that I could use to resize the UITextView appropriately because all examples I find online do not work somehow.
the code
- (void)keyboardWasShown:(NSNotification *)notification {
CGRect viewFrame = input.frame;
CGFloat textEndCord = CGRectGetMaxY(input.frame);
CGFloat kbStartCord = input.frame.size.height - ([[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]).size.height;
CGFloat result = fabsf( input.frame.size.height - fabsf( textEndCord - kbStartCord ));
viewFrame.size.height -= result;
NSLog(@"Original Height:%f, TextView End Cord: %f, KB Start Cord: %f, resutl: %f, the sum: %f",input.frame.size.height, textEndCord,kbStartCord,result,fabsf( textEndCord - kbStartCord ));
input.frame = viewFrame;
}