reactjs - 很难在 Android 中选择 TextInput 条目
问题描述
我不知道为什么在 Android 中选择输入如此困难,我一直按 TextInput 但无论输入是否为空,都不会显示全选、粘贴或复制选项。在 iOS 中它运行良好!
<View style={styles.reporterView}>
<Text style={styles.reporterText}>Reporter:</Text>
<TextInput
value={this.state.reporter}
onChangeText={(reporter) => this.setState({reporter})}
style={styles.reporterField}
placeholder={'Name'}
autoCorrect={false}
textAlign={'left'}
maxLength={20}
scrollEnabled={false}
/>
</View>
reporterView: {
flex: 1,
flexDirection: 'row',
marginBottom: 25,
paddingTop: 15,
paddingLeft: '22%'
},
reporterField: {
flex: 1,
fontSize: 22,
height: 55,
marginLeft: 30,
marginTop: Platform.OS == 'android' ? -12 : 0
}
解决方案
这看起来像是 React-Native 和 Android 的常见问题。我从支持页面中找到了一个似乎运行良好的解决方案。
removeClippedSubviews
默认设置为true
。所以你必须把它设置为false
这些是找到它并设置为 false 的可能路径;
..\node_modules\react-navigation-material-bottom-tabs\node_modules\react-navigation-tabs\src\views\ResourceSavingScene.js
..\node_modules\react-navigation-tabs\src\views\ResourceSavingScene.js
..\node_modules\react-navigation-drawer\dist\view\ResourceSavingScene.js
..\node_modules\react-navigation-material-bottom-tabs\node_modules\react-navigation-tabs\dist\views\ResourceSavingScene.js
..\node_modules\react-native-paper\src\components\BottomNavigation.js
--
这是要使用的代码
removeClippedSubviews={
// On iOS, set removeClippedSubviews to true only when not focused
// This is an workaround for a bug where the clipped view never re-appears
Platform.OS === 'ios' ? navigationState.index !== index : true //<-- set this to false
}
参考:https ://github.com/facebook/react-native/issues/25038
以下是 Git 和 stackoverflow 上的其他解决方案。让我知道这些是否有帮助。
Stackoverflow:在 TextInput 中启用粘贴和选择 - React Native
推荐阅读
- java - 按 id 显示单行 - spring mvc
- c++ - 为一个类实现 Boost::Asio 的行为
- javascript - 无法在 php 中回显 ajax .load 函数
- firebase - 是否可以在云 Firestore 上查询字段并获取主集合字段并使用子集合文档获取子集合?
- ios - 在 ChildView 中预览 Core Data 实体
- html - 基于单击 Vuejs 中的按钮显示/隐藏警报
- c++ - 带有 constexpr 声明变量的奇怪错误 C2131
- javascript - 我收到 javascript 错误,例如 Uncaught TypeError: Cannot set property 'user' of undefined 当我单击添加注释按钮时
- c# - C# 与列表相交
- c - scons: 警告: 不推荐在没有错误的情况下调用缺少的 SConscript