Open edward-s opened 9 years ago
Seeing this with SwiftKey.
Same. Anybody have any idea how to fix?
you can fix it by doing the following:
in the Keyboard_willShow method add this:
viewableHeight = MIN(352, viewableHeight); // 352 is the height of the secure keyboard so make it at least that tall (probably better way to calculate it)
also in the Keyboard_willHide add all the way at the end:
[self setContentOffset:CGPointMake(0,0)];
this works for me
@implementation TPKeyboardAvoidingState
override keyboardVisible getter can fix the problem
I'm not sure why it works (not having looked at this in detail), but the code that @dcty posted work very well for me. @dcty, do you intend to make a pull request?
@dcty fix doesn't work well for me. When I dismiss keyboard my buttons at the bottom of the screen are off the screen because the state.priorScrollIndicatorInsets and state.priorInset don't get reset to correct values.
This should fix both issues.
- (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
TPKeyboardAvoidingState *state = self.keyboardAvoidingState;
if ( state.keyboardVisible ) {
return;
}
UIView *firstResponder = [self TPKeyboardAvoiding_findFirstResponderBeneathView:self];
state.keyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
if (state.keyboardRect.size.height != 0) {
state.keyboardVisible = YES;
state.priorInset = self.contentInset;
state.priorScrollIndicatorInsets = self.scrollIndicatorInsets;
if ( [self isKindOfClass:[TPKeyboardAvoidingScrollView class]] ) {
state.priorContentSize = self.contentSize;
if ( CGSizeEqualToSize(self.contentSize, CGSizeZero) ) {
// Set the content size, if it's not set. Do not set content size explicitly if auto-layout
// is being used to manage subviews
self.contentSize = [self TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames];
}
}
// Shrink view's inset by the keyboard's height, and scroll to show the text field/view being edited
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
self.contentInset = [self TPKeyboardAvoiding_contentInsetForKeyboard];
if ( firstResponder ) {
CGFloat viewableHeight = self.bounds.size.height - self.contentInset.top - self.contentInset.bottom;
[self setContentOffset:CGPointMake(self.contentOffset.x,
[self TPKeyboardAvoiding_idealOffsetForView:firstResponder
withViewingAreaHeight:viewableHeight])
animated:NO];
}
self.scrollIndicatorInsets = self.contentInset;
[UIView commitAnimations];
}
}
it seems like if I use iOS 8.0 custom keyboard i.e: swiftkey, flesky
the scrollview does not adjust properly
further debugging indicates that state.keyboardRect.height is always 0 when using custom keyboard
any idea how to fix this?