From 947ec74c9e573a41b3302cb991d67900b05d747c Mon Sep 17 00:00:00 2001 From: andrew lattis Date: Tue, 5 Mar 2013 14:03:22 -0600 Subject: [PATCH] swipe gesture bug fixes the previous text view content size doesn't get reset every time editing starts. scrollview insets work now when the keyboard is minimized. --- .../MessagesViewController.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/MessagesTableViewController/MessagesViewController.m b/MessagesTableViewController/MessagesViewController.m index adf37c2..fa7d188 100644 --- a/MessagesTableViewController/MessagesViewController.m +++ b/MessagesTableViewController/MessagesViewController.m @@ -70,10 +70,10 @@ // Swipe guesture for pull to hide keyboard // Too buggy, needs work - //UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; - //swipe.direction = UISwipeGestureRecognizerDirectionDown; - //swipe.numberOfTouchesRequired = 1; - //[self.inputView addGestureRecognizer:swipe]; + UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; + swipe.direction = UISwipeGestureRecognizerDirectionDown; + swipe.numberOfTouchesRequired = 1; + [self.inputView addGestureRecognizer:swipe]; } #pragma mark - View lifecycle @@ -218,7 +218,8 @@ - (void)textViewDidBeginEditing:(UITextView *)textView { [textView becomeFirstResponder]; - self.previousTextViewContentHeight = textView.contentSize.height; + if (!self.previousTextViewContentHeight) + self.previousTextViewContentHeight = textView.contentSize.height; [self scrollToBottomAnimated:YES]; } @@ -287,14 +288,15 @@ keyboardY - inputViewFrame.size.height, inputViewFrame.size.width, inputViewFrame.size.height); - + UIEdgeInsets insets = UIEdgeInsetsMake(0.0f, 0.0f, - self.view.frame.size.height - keyboardY, + self.view.frame.size.height - self.inputView.frame.origin.y - INPUT_HEIGHT, 0.0f); + self.tableView.contentInset = insets; self.tableView.scrollIndicatorInsets = insets; - + [UIView commitAnimations]; }