Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {

state.animationDuration = [[info objectForKey:kUIKeyboardAnimationDurationUserInfoKey] doubleValue];

CGRect beginKeyboardRect = [self convertRect:[[info objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil];
CGRect endKeyboardRect = [self convertRect:[[info objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
CGRect beginKeyboardRect = [[info objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endKeyboardRect = [[info objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue];
if (CGRectIsEmpty(endKeyboardRect)) {
self.keyboardAvoidingState.keyboardVisible = NO;
return;
Expand Down Expand Up @@ -138,8 +138,8 @@ - (void)keyboardViewDisappear:(NSString *)animationID finished:(NSNumber *)finis
}

- (void)TPKeyboardAvoiding_keyboardWillHide:(NSNotification*)notification {
CGRect beginKeyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue] fromView:nil];
CGRect endKeyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
CGRect beginKeyboardRect = [[[notification userInfo] objectForKey:_UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect endKeyboardRect = [[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue];
if (CGRectIsEmpty(beginKeyboardRect) && !self.keyboardAvoidingState.keyboardAnimationInProgress) {
return;
}
Expand Down Expand Up @@ -357,7 +357,11 @@ - (UIEdgeInsets)TPKeyboardAvoiding_contentInsetForKeyboard {
if (keyboardRect.size.height == 0) {
newInset.bottom = state.priorInset.bottom;
} else {
newInset.bottom = MAX(keyboardRect.size.height - MAX((CGRectGetMaxY(keyboardRect) - CGRectGetMaxY(self.bounds)), 0), 0);
CGRect frameInWindowCoordinateSpace = [self.superview convertRect:self.frame toView:nil];
CGRect intersection = CGRectIntersection(keyboardRect, frameInWindowCoordinateSpace);
if (! CGRectIsNull(intersection)) {
newInset.bottom = intersection.size.height;
}
}

return newInset;
Expand Down