我正在为我父亲的公司开发一个库存系统,其中之一的要求是能够使用外部条形码/二维码扫描器。
我已经使用相机开发了所有内容,但我真的需要使用扫描器而不显示键盘。
你们中的任何人知道是否可能吗?如果不行,还有其他方法吗?
我已经使用相机开发了所有内容,但我真的需要使用扫描器而不显示键盘。
你们中的任何人知道是否可能吗?如果不行,还有其他方法吗?
showSoftInputOnFocus
的属性。将其设置为false可以隐藏键盘。
<TextInput showSoftInputOnFocus={false} autoFocus={true}..../>
在v0.60.0版本中对我有效。现在可以在iOS和Android上使用,无需任何属性即可将TouchableOpacity与ScrollView包装在一起,以使点击打开键盘的功能正常工作!
const [openKeyboard, setOpenKeyboard] = useState(autoFocus);
const onPressInput = useCallback(() => {
inputRef.current.focus();
setOpenKeyboard(true)
}, [inputRef]);
<ScrollView
>
<TouchableOpacity
activeOpacity={1}
style={[styles.container, style]}
onPress={onPressInput}
>
{renderInputBox()}
<View style={{ width: 0, height: 0 }}>
<TextInput
keyboardType="numeric"
returnKeyType="done"
autoFocus={openKeyboard}
maxLength={codeLength}
ref={inputRef}
/>
</View>
</TouchableOpacity>
</ScrollView>