![](/img/trans.png)
[英]Keyboard dismiss immediately when focusing textInput for first time react native
[英]Lose focus and dismiss keyboard on clicking outside of the TextInput field in react native?
我已經對此進行了研究並找到了這篇文章:
但這對我不起作用。 當我觸摸屏幕上文本輸入字段之外的部分時,我期望輸入字段將失去焦點,並且鍵盤將被關閉。 但是,什么都沒有發生。 光標在輸入上持續閃爍。
下面是我嘗試的代碼。 請注意,我正在使用redux-form v6:
import dismissKeyboard from 'dismissKeyboard';
<TouchableWithoutFeedback onPress={()=> dismissKeyboard()}>
<View style={styles.inputWrap}>
<Field name="editLocation" component={TextField} />
<Button onPress={handleSubmit(this.onSubmit)}>Sign In</Button>
</View>
</TouchableWithoutFeedback>
TextField組件包含TextInput。 不知道我做錯了什么。
我已經在Genymotion模擬器上使用Samsung S6圖像和三星Note 4測試了代碼。
您需要檢查TouchableWithoutFeedback
的尺寸,以確保調用了onPress
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.