From 3b3e6a0eb3e36b6df61b789765bcacbc069729f1 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 27 Feb 2019 18:21:51 -0800 Subject: [PATCH] Fixed onScroll prop in mulitline TextInput (#23668) Summary: We lose the support of `onScroll` prop for multiline TextInput, let's add it again. [iOS] [Fixed] - Fixed onScroll prop in mulitline TextInput Pull Request resolved: https://github.com/facebook/react-native/pull/23668 Differential Revision: D14253996 Pulled By: cpojer fbshipit-source-id: 43ed191e18fdb716f6c53be3bf0f59f917b34b59 --- Libraries/Text/TextInput/RCTBackedTextInputDelegate.h | 4 ++++ .../Text/TextInput/RCTBackedTextInputDelegateAdapter.m | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h b/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h index 4beb21bc9..f711fe683 100644 --- a/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +++ b/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h @@ -27,6 +27,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)textInputDidChangeSelection; +@optional + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView; + @end NS_ASSUME_NONNULL_END diff --git a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m index 754210355..fe5ee6764 100644 --- a/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m +++ b/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.m @@ -213,6 +213,15 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo [self textViewProbablyDidChangeSelection]; } +#pragma mark - UIScrollViewDelegate + +- (void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if ([_backedTextInputView.textInputDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) { + [_backedTextInputView.textInputDelegate scrollViewDidScroll:scrollView]; + } +} + #pragma mark - Public Interface - (void)skipNextTextInputDidChangeSelectionEventWithTextRange:(UITextRange *)textRange