键盘活动时忽略屏幕的其余部分 [英] Ignore rest of screen when keyboard active

查看:56
本文介绍了键盘活动时忽略屏幕的其余部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在为我的应用程序添加最后的润色,并且存在一段时间的一个错误是当键盘处于活动状态时,我可以使用屏幕上半部分的导航,而键盘仍然显示

So i am adding the final touches to my application, and one bug that has been present for a while is when they keyboard is active, i am able to use the navigation on the upper half of the screen with the keyboard still showing

当键盘处于活动状态时,是否有一种简单的方法可以消除屏幕上半部分的所有其他触摸?如果你能指出我正确的方向,那就太好了.

Is there a simple way to dismiss all other touches on the upper half of the screen when the keyboard is active? If you could point me in the right direction that would be great.

寻找与此类似的内容:当键盘处于活动状态时触摸屏幕任意位置,关闭键盘

如果键盘输出的 textInput 仍然是可触摸的,那就太好了

would be nice if the textInput that the keyboard is outputting to was still touchable

推荐答案

如果 TextInput 的父视图是 ScrollView,那么你可以使用 prop 'keyboardShouldPersistTaps',

If the parent view of the TextInput is a ScrollView, then u can use the prop 'keyboardShouldPersistTaps',

<ScrollView keyboardShouldPersistTaps='handled'/>

如果您使用的是 View 并且不想滚动,那么您可能可以将其包裹在

If you're using a View and dont want scrolling, then probably u can wrap it inside a

//This should disable scroll
<ScrollView scrollEnabled={false} >

keyboardShouldPersistTaps(React Native 网站)的文档

keyboardShouldPersistTaps?: enum('always', 'never', 'handled', false,真)#

keyboardShouldPersistTaps?: enum('always', 'never', 'handled', false, true) #

确定点击后键盘何时应保持可见.

Determines when the keyboard should stay visible after a tap.

'never'(默认),在焦点文本输入之外点击键盘向上关闭键盘.遇到这种情况,孩子不会收到水龙头.'always',键盘不会关闭自动,滚动视图不会捕捉点击,但孩子滚动视图可以捕捉点击.'handled',键盘不会当孩子处理水龙头时自动关闭,(或被祖先俘虏).错误,已弃用,使用从不"代替 true,已弃用,请改用始终"

'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap. 'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps. 'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor). false, deprecated, use 'never' instead true, deprecated, use 'always' instead

这篇关于键盘活动时忽略屏幕的其余部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆