Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何让键盘不消失 #9

Closed
fukuaxiaoqiang opened this issue Jun 23, 2017 · 1 comment
Closed

如何让键盘不消失 #9

fukuaxiaoqiang opened this issue Jun 23, 2017 · 1 comment

Comments

@fukuaxiaoqiang
Copy link

点击发送的时候 如何输入框不失去焦点且键盘不消失

@plusmancn
Copy link
Member

源代码在逻辑上是矛盾的,要更改 RN 的源代码,iOS 可以如下实现,但是代价有点大。
OC 源码中 是在 shouldChangeTextInRange 事件捕获 "\n" 字符串来实现 return key 的,如果_blurOnSubmit 为 true 则捕获

源码:https://github.com/facebook/react-native/blob/0e55f5b26dc60d8ce37e49b4766d7e9ec0a57605/Libraries/Text/RCTTextView.m#L349-L380

然后在 textFieldShouldEndEditing 之中,通过 _blurOnSubmit 来是判断键盘是否需要 dismiss,如果 _blurOnSubmit 为 false 则保持 keyBoard

源码:https://github.com/facebook/react-native/blob/0e55f5b26dc60d8ce37e49b4766d7e9ec0a57605/Libraries/Text/RCTTextField.m#L202-L209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants