[
https://issues.apache.org/jira/browse/WEEX-434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16696425#comment-16696425
]
ASF GitHub Bot commented on WEEX-434:
-------------------------------------
wqyfavor closed pull request #1297: [WEEX-434][iOS] Fix the input cannot move
down to original position.…
URL: https://github.com/apache/incubator-weex/pull/1297
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.mm
b/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.mm
index d4f2488558..b8b27c312b 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXEditComponent.mm
@@ -73,6 +73,9 @@ @interface WXEditComponent()
// disable move rootView up as the keyboard show up.
@property (nonatomic, assign) BOOL disableMoveViewUp;
+// avoid keyboardWillHide executes twice
+@property (nonatomic, assign) BOOL keyboardHidden;
+
@end
@implementation WXEditComponent
@@ -98,6 +101,7 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString
*)type styles:(NSDict
_returnEvent = NO;
_clickEvent = NO;
_keyboardEvent = NO;
+ _keyboardHidden = YES;
// handle attributes
_autofocus = [attributes[@"autofocus"] boolValue];
_disabled = [attributes[@"disabled"] boolValue];
@@ -220,6 +224,7 @@ -(void)focus
-(void)blur
{
if(self.view) {
+ [[NSNotificationCenter defaultCenter]
postNotificationName:UIKeyboardWillHideNotification object:nil];
[self.view resignFirstResponder];
}
}
@@ -659,7 +664,7 @@ - (void)setViewMovedUp:(BOOL)movedUp
CGRect rootViewFrame = rootView.frame;
CGRect inputFrame = [self.view.superview convertRect:self.view.frame
toView:rootView];
if (movedUp) {
- CGFloat offset =
inputFrame.origin.y-(rootViewFrame.size.height-_keyboardSize.height-inputFrame.size.height);
+ CGFloat offset =
inputFrame.origin.y-(rootViewFrame.size.height-_keyboardSize.height-inputFrame.size.height)
+ 20;
if (offset > 0) {
rect = (CGRect){
.origin.x = 0.f,
@@ -889,11 +894,13 @@ - (void)keyboardWasShown:(NSNotification*)notification
if (_keyboardEvent) {
[self fireEvent:@"keyboard" params:@{ @"isShow": @YES }];
}
+
+ _keyboardHidden = NO;
}
- (void)keyboardWillHide:(NSNotification*)notification
{
- if (![self.view isFirstResponder]) {
+ if (![self.view isFirstResponder] || _keyboardHidden) {
return;
}
if (!_disableMoveViewUp) {
@@ -906,10 +913,13 @@ - (void)keyboardWillHide:(NSNotification*)notification
if (_keyboardEvent) {
[self fireEvent:@"keyboard" params:@{ @"isShow": @NO }];
}
+
+ _keyboardHidden = YES;
}
- (void)closeKeyboard
{
+ [[NSNotificationCenter defaultCenter]
postNotificationName:UIKeyboardWillHideNotification object:nil];
[self.view resignFirstResponder];
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> WXRootView cannot reset to original position
> --------------------------------------------
>
> Key: WEEX-434
> URL: https://issues.apache.org/jira/browse/WEEX-434
> Project: Weex
> Issue Type: Bug
> Components: iOS
> Reporter: weifengsmile
> Assignee: acton393
> Priority: Major
> Attachments: 屏幕快照 2018-06-04 下午5.28.47.png, 屏幕快照 2018-06-04
> 下午5.29.09.png, 屏幕快照 2018-06-04 下午5.30.43.png
>
>
> Reproduce condition: the input component is on the bottom of page.
> When the input component moved up as keyboard shown, the keyboard
> Preselection view or toolbar view will cover a part of the input component.
> And WXRootView cannot move to original position after keyboard hiden.
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)