Created
January 2, 2014 09:19
-
-
Save MP0w/8216753 to your computer and use it in GitHub Desktop.
Fix iOS 7 texview that doesn't scroll properly while you type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)textViewDidChange:(UITextView *)textView { | |
CGRect line = [textView caretRectForPosition: | |
textView.selectedTextRange.start]; | |
CGFloat overflow = line.origin.y + line.size.height | |
- ( textView.contentOffset.y + textView.bounds.size.height | |
- textView.contentInset.bottom - textView.contentInset.top ); | |
if ( overflow > 0 ) { | |
CGPoint offset = textView.contentOffset; | |
offset.y += overflow + 7; | |
[UIView animateWithDuration:.2 animations:^{ | |
[textView setContentOffset:offset]; | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment