gpt4 book ai didi

react 原生键盘自动隐藏问题

转载 作者:行者123 更新时间:2023-12-03 17:24:33 26 4
gpt4 key购买 nike

目前,我正在开发一个 react-native 应用程序。问题是,当我触摸文本输入框时,键盘仅在每次重新启动我的应用程序时第一次自动隐藏。
我的 TextInput 组件在这里:

<TextInput
blurOnSubmit={false}
placeholder={"Email..."}
autoCapitalize="none"
style={{
height: 40,
paddingLeft: 10,
fontSize: 18,
fontWeight: "bold",
width: "90%",
}}
onChangeText={(email) => {
this.setState({ email });
this.validateEmail(email).then((res) => this.handleResponse(res));
}}
value={this.state.email}
ref={(ref) => (this.email = ref)}
onSubmitEditing={() => this.mobile.focus()}
/>
我的 Package.json 依赖项
  "dependencies": {
"@react-native-community/async-storage": "^1.11.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/bottom-tabs": "^5.5.2",
"@react-navigation/drawer": "^5.8.2",
"@react-navigation/native": "^5.5.1",
"@react-navigation/stack": "^5.5.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-datepicker": "^1.7.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-looped-carousel": "^0.1.13",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.5",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "^2.8.0",
"react-native-vector-icons": "^6.6.0"
},

最佳答案

你可以像下面这样修改你的 AndroidManifest.xml,这个错误出现在 React Native 中 >59 以上。

  <application
android:name=".MainApplication"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

然后保存并再次运行您的应用程序项目。

关于 react 原生键盘自动隐藏问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62556133/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com