问题描述
我有一个跨平台的应用程序.我有一个具有多个TextField的表单.当用户触摸文本框之外时,我想隐藏键盘,因为它覆盖了发送数据的按钮.
我该怎么办?
在我的.html文件中,我有:
<ScrollView>
<GridLayout ios:style="margin-top:50">
<StackLayout class="form">
<!-- Some TextView -->
</StackLayout>
</GridLayout>
</ScrollView>
编辑
这是显示错误的游乐场. /p>
在布局中添加一个tap
侦听器,并使用
iOS
import * as utils from "tns-core-modules/utils/utils";
UIApplication.sharedApplication
.keyWindow
.endEditing(true);
Android
utils.ad.dismissSoftInput();
修改
如果Page
中只有一个TextField
,则可以只在TextField
上调用dismissSoftInput()
方法.如果您在Page
上有多个TextField
,并且不确定实际上是哪个焦点,那么上面的代码会有所帮助.
I have a cross-platform app. I have a form that has more than one TextField. I want to hide the keyboard when the user touch outside of the textfield because it covers the button that sends the data.
How can I do?
In my .html file I have:
<ScrollView>
<GridLayout ios:style="margin-top:50">
<StackLayout class="form">
<!-- Some TextView -->
</StackLayout>
</GridLayout>
</ScrollView>
EDIT
This is a Playground that show the error.
Add a tap
listener to your layout and hide keyboard using
iOS
import * as utils from "tns-core-modules/utils/utils";
UIApplication.sharedApplication
.keyWindow
.endEditing(true);
Android
utils.ad.dismissSoftInput();
Edit
You may simply call dismissSoftInput()
method on the TextField
if it's just one TextField
in your Page
. The above code helps if you have multiple TextField
s on your Page
and not sure which one is actually focused.
这篇关于触摸文本框外后如何隐藏键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!