From 5d5cc79f681d6fb7e954bc0029833861976232b1 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 14 Jun 2024 17:58:19 +0800 Subject: [PATCH 1/2] fix(ios): responsable region issue of Textinput --- .../component/textinput/HippyTextView.mm | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextView.mm b/renderer/native/ios/renderer/component/textinput/HippyTextView.mm index de672c4cc3b..8a2f3f861a4 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextView.mm +++ b/renderer/native/ios/renderer/component/textinput/HippyTextView.mm @@ -282,21 +282,23 @@ - (void)updateFrames { } - (void)updateContentSize { - CGSize size = (CGSize) { _scrollView.frame.size.width, INFINITY }; - size.height = [_textView sizeThatFits:size].height; - _scrollView.contentSize = size; - _textView.frame = (CGRect) { CGPointZero, size }; - - if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, size)) { - _previousContentSize = size; + CGSize contentSize = (CGSize) { CGRectGetMaxX(_scrollView.frame), INFINITY }; + contentSize.height = [_textView sizeThatFits:contentSize].height; + + if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, contentSize)) { + _previousContentSize = contentSize; _onContentSizeChange(@{ @"contentSize": @ { - @"height": @(size.height), - @"width": @(size.width), + @"height": @(contentSize.height), + @"width": @(contentSize.width), }, @"target": self.hippyTag, }); } + + CGSize viewSize = CGSizeMake(CGRectGetWidth(_scrollView.frame), MAX(contentSize.height, self.frame.size.height)); + _scrollView.contentSize = viewSize; + _textView.frame = (CGRect) { CGPointZero, viewSize }; } - (void)updatePlaceholder { From 3a2a38daea1d5170c42fad09c0e47f62ffbdc7f9 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 14 Jun 2024 17:58:59 +0800 Subject: [PATCH 2/2] chore(ios): remove unused code in TextView --- .../ios/renderer/component/textinput/HippyTextField.h | 2 -- .../ios/renderer/component/textinput/HippyTextField.m | 7 ------- .../ios/renderer/component/textinput/HippyTextView.h | 1 - .../ios/renderer/component/textinput/HippyTextView.mm | 8 -------- 4 files changed, 18 deletions(-) diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextField.h b/renderer/native/ios/renderer/component/textinput/HippyTextField.h index 2766e869aed..0b61e7c9f82 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextField.h +++ b/renderer/native/ios/renderer/component/textinput/HippyTextField.h @@ -43,7 +43,6 @@ @interface HippyTextField : HippyBaseTextInput @property (nonatomic, copy) HippyDirectEventBlock onKeyPress; @property (nonatomic, assign) BOOL autoCorrect; -//@property (nonatomic, assign) UIEdgeInsets contentInset; @property (nonatomic, strong) UIColor *placeholderTextColor; @property (nonatomic, strong) NSString *placeholder; @property (nonatomic, strong) NSNumber *maxLength; @@ -62,7 +61,6 @@ @property (nonatomic, copy) HippyDirectEventBlock onKeyboardWillHide; @property (nonatomic, copy) NSString *value; -@property (nonatomic, strong) NSNumber *fontSize; @property (nonatomic, strong) NSString *defaultValue; @property (nonatomic, copy) NSString *text; @property (nonatomic, strong) UIColor *textColor; diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextField.m b/renderer/native/ios/renderer/component/textinput/HippyTextField.m index ef69c22806f..10137be9b6d 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextField.m +++ b/renderer/native/ios/renderer/component/textinput/HippyTextField.m @@ -359,13 +359,6 @@ - (void)setText:(NSString *)text { _text = text; } -- (void)setFontSize:(NSNumber *)fontSize { - _fontSize = fontSize; - if ([fontSize floatValue] > 0) { - [_textView setFont:[UIFont systemFontOfSize:[fontSize floatValue]]]; - } -} - - (void)setValue:(NSString *)value { [_textView setText:value]; } diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextView.h b/renderer/native/ios/renderer/component/textinput/HippyTextView.h index 4eebb1e6f1b..2a48201b8e8 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextView.h +++ b/renderer/native/ios/renderer/component/textinput/HippyTextView.h @@ -60,7 +60,6 @@ - (void)performTextUpdate; @property (nonatomic, copy) NSString *value; -@property (nonatomic, strong) NSNumber *fontSize; @property (nonatomic, strong) NSString *defaultValue; @property (nonatomic, strong) UIColor *textColor; diff --git a/renderer/native/ios/renderer/component/textinput/HippyTextView.mm b/renderer/native/ios/renderer/component/textinput/HippyTextView.mm index 8a2f3f861a4..eb13261d753 100644 --- a/renderer/native/ios/renderer/component/textinput/HippyTextView.mm +++ b/renderer/native/ios/renderer/component/textinput/HippyTextView.mm @@ -745,14 +745,6 @@ - (void)setValue:(NSString *)value { [self setText:value]; } -- (void)setFontSize:(NSNumber *)fontSize { - _fontSize = fontSize; - - if ([fontSize floatValue] > 0) { - [self setFont:[UIFont systemFontOfSize:[fontSize floatValue]]]; - } -} - - (void)setDefaultValue:(NSString *)defaultValue { if (defaultValue) { [self setText:defaultValue];