diff --git a/ios/sdk/component/textinput/HippyTextField.h b/ios/sdk/component/textinput/HippyTextField.h index f8329493eda..77fc8b4028d 100644 --- a/ios/sdk/component/textinput/HippyTextField.h +++ b/ios/sdk/component/textinput/HippyTextField.h @@ -35,12 +35,13 @@ @end @interface HippyUITextField : UITextField +/// iOS18's UITextInput adds an `editable` property, to avoid conflict, rename to `canEdit` +@property (nonatomic, assign) BOOL canEdit; @property (nonatomic, assign) BOOL textWasPasted; @property (nonatomic, weak) id responderDelegate; @property (nonatomic, copy) HippyDirectEventBlock onBlur; @property (nonatomic, copy) HippyDirectEventBlock onFocus; -@property (nonatomic, assign) BOOL editable; @end @interface HippyTextField : HippyBaseTextInput diff --git a/ios/sdk/component/textinput/HippyTextField.m b/ios/sdk/component/textinput/HippyTextField.m index ed4f0e5050a..7789ae16af5 100644 --- a/ios/sdk/component/textinput/HippyTextField.m +++ b/ios/sdk/component/textinput/HippyTextField.m @@ -43,9 +43,9 @@ - (void)setKeyboardType:(UIKeyboardType)keyboardType { self.text = tempPwdStr; } -- (void)setEditable:(BOOL)editable { - _editable = editable; - [self setEnabled:editable]; +- (void)setCanEdit:(BOOL)canEdit { + _canEdit = canEdit; + [self setEnabled:canEdit]; } - (void)paste:(id)sender { diff --git a/ios/sdk/component/textinput/HippyTextView.h b/ios/sdk/component/textinput/HippyTextView.h index f52fc60802a..a2aeefefded 100644 --- a/ios/sdk/component/textinput/HippyTextView.h +++ b/ios/sdk/component/textinput/HippyTextView.h @@ -35,6 +35,9 @@ @end @interface HippyUITextView : UITextView +/// iOS18's UITextInput adds an `editable` property, which conflicts with the one defined in HippyUITextField. +/// For consistency, we added a canEdit property here too, which has the same meaning as editable +@property (nonatomic, assign) BOOL canEdit; @property (nonatomic, assign) BOOL textWasPasted; @property (nonatomic, weak) id responderDelegate; @end diff --git a/ios/sdk/component/textinput/HippyTextView.mm b/ios/sdk/component/textinput/HippyTextView.mm index 1f605c7b4fc..f40c6164509 100644 --- a/ios/sdk/component/textinput/HippyTextView.mm +++ b/ios/sdk/component/textinput/HippyTextView.mm @@ -73,6 +73,11 @@ - (void)didMoveToWindow { } } +- (void)setCanEdit:(BOOL)canEdit { + _canEdit = canEdit; + [self setEditable:canEdit]; +} + @end @interface HippyTextView () diff --git a/ios/sdk/component/textinput/HippyTextViewManager.mm b/ios/sdk/component/textinput/HippyTextViewManager.mm index 70478e91d51..be767c373ec 100644 --- a/ios/sdk/component/textinput/HippyTextViewManager.mm +++ b/ios/sdk/component/textinput/HippyTextViewManager.mm @@ -182,7 +182,7 @@ - (HippyShadowView *)shadowView { HIPPY_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL) HIPPY_REMAP_VIEW_PROPERTY(color, textView.textColor, UIColor) HIPPY_REMAP_VIEW_PROPERTY(textAlign, textView.textAlignment, NSTextAlignment) -HIPPY_REMAP_VIEW_PROPERTY(editable, textView.editable, BOOL) +HIPPY_REMAP_VIEW_PROPERTY(editable, textView.canEdit, BOOL) HIPPY_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL) HIPPY_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType) HIPPY_REMAP_VIEW_PROPERTY(keyboardAppearance, textView.keyboardAppearance, UIKeyboardAppearance)