Skip to content

Commit

Permalink
Merge pull request #78 from phatmann/work-without-first-responder
Browse files Browse the repository at this point in the history
Work without firstResponder
  • Loading branch information
michaeltyson committed Jan 17, 2014
2 parents e88f3ac + 61bc975 commit 5fc610e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions TPKeyboardAvoiding/UIScrollView+TPKeyboardAvoidingAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
}

UIView *firstResponder = [self TPKeyboardAvoiding_findFirstResponderBeneathView:self];
if ( !firstResponder ) {
// No child view is the first responder - nothing to do here
return;
}

state.keyboardRect = [self convertRect:[[[notification userInfo] objectForKey:_UIKeyboardFrameEndUserInfoKey] CGRectValue] fromView:nil];
state.keyboardVisible = YES;
Expand All @@ -71,13 +67,17 @@ - (void)TPKeyboardAvoiding_keyboardWillShow:(NSNotification*)notification {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];

self.contentInset = [self TPKeyboardAvoiding_contentInsetForKeyboard];
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];

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];
Expand Down

0 comments on commit 5fc610e

Please sign in to comment.