Skip to content

Commit 7a2ce1d

Browse files
committed
fix(ios): responsable region issue of Textinput (#3932)
* fix(ios): responsable region issue of Textinput * chore(ios): remove unused code in TextView
1 parent f717db5 commit 7a2ce1d

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

renderer/native/ios/renderer/component/textinput/HippyTextField.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
@interface HippyTextField : HippyBaseTextInput <UITextFieldDelegate>
4444
@property (nonatomic, copy) HippyDirectEventBlock onKeyPress;
4545
@property (nonatomic, assign) BOOL autoCorrect;
46-
//@property (nonatomic, assign) UIEdgeInsets contentInset;
4746
@property (nonatomic, strong) UIColor *placeholderTextColor;
4847
@property (nonatomic, strong) NSString *placeholder;
4948
@property (nonatomic, strong) NSNumber *maxLength;
@@ -62,7 +61,6 @@
6261
@property (nonatomic, copy) HippyDirectEventBlock onKeyboardWillHide;
6362

6463
@property (nonatomic, copy) NSString *value;
65-
@property (nonatomic, strong) NSNumber *fontSize;
6664
@property (nonatomic, strong) NSString *defaultValue;
6765
@property (nonatomic, copy) NSString *text;
6866
@property (nonatomic, strong) UIColor *textColor;

renderer/native/ios/renderer/component/textinput/HippyTextField.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,6 @@ - (void)setText:(NSString *)text {
355355
_text = text;
356356
}
357357

358-
- (void)setFontSize:(NSNumber *)fontSize {
359-
_fontSize = fontSize;
360-
if ([fontSize floatValue] > 0) {
361-
[_textView setFont:[UIFont systemFontOfSize:[fontSize floatValue]]];
362-
}
363-
}
364-
365358
- (void)setValue:(NSString *)value {
366359
[_textView setText:value];
367360
}

renderer/native/ios/renderer/component/textinput/HippyTextView.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
- (void)performTextUpdate;
6161

6262
@property (nonatomic, copy) NSString *value;
63-
@property (nonatomic, strong) NSNumber *fontSize;
6463
@property (nonatomic, strong) NSString *defaultValue;
6564
@property (nonatomic, strong) UIColor *textColor;
6665
@property (nonatomic, copy) HippyDirectEventBlock onChangeText;

renderer/native/ios/renderer/component/textinput/HippyTextView.mm

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,23 @@ - (void)updateFrames {
273273
}
274274

275275
- (void)updateContentSize {
276-
CGSize size = (CGSize) { _scrollView.frame.size.width, INFINITY };
277-
size.height = [_textView sizeThatFits:size].height;
278-
_scrollView.contentSize = size;
279-
_textView.frame = (CGRect) { CGPointZero, size };
280-
281-
if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, size)) {
282-
_previousContentSize = size;
276+
CGSize contentSize = (CGSize) { CGRectGetMaxX(_scrollView.frame), INFINITY };
277+
contentSize.height = [_textView sizeThatFits:contentSize].height;
278+
279+
if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, contentSize)) {
280+
_previousContentSize = contentSize;
283281
_onContentSizeChange(@{
284282
@"contentSize": @ {
285-
@"height": @(size.height),
286-
@"width": @(size.width),
283+
@"height": @(contentSize.height),
284+
@"width": @(contentSize.width),
287285
},
288286
@"target": self.hippyTag,
289287
});
290288
}
289+
290+
CGSize viewSize = CGSizeMake(CGRectGetWidth(_scrollView.frame), MAX(contentSize.height, self.frame.size.height));
291+
_scrollView.contentSize = viewSize;
292+
_textView.frame = (CGRect) { CGPointZero, viewSize };
291293
}
292294

293295
- (void)updatePlaceholder {
@@ -689,14 +691,6 @@ - (void)setValue:(NSString *)value {
689691
[self setText:value];
690692
}
691693

692-
- (void)setFontSize:(NSNumber *)fontSize {
693-
_fontSize = fontSize;
694-
695-
if ([fontSize floatValue] > 0) {
696-
[self setFont:[UIFont systemFontOfSize:[fontSize floatValue]]];
697-
}
698-
}
699-
700694
- (void)setDefaultValue:(NSString *)defaultValue {
701695
if (defaultValue) {
702696
[self setText:defaultValue];

0 commit comments

Comments
 (0)