Javascript 反应本机键盘避免视图不工作
请不要将此标记为重复。它不是。我还没有找到任何有效的解决办法 所以,基本上,我一直在浏览stackoverflow和GitHub,我什么都没找到。如果我将Javascript 反应本机键盘避免视图不工作,javascript,reactjs,react-native,Javascript,Reactjs,React Native,请不要将此标记为重复。它不是。我还没有找到任何有效的解决办法 所以,基本上,我一直在浏览stackoverflow和GitHub,我什么都没找到。如果我将KeyboardAvoidingView的行为设置为padding则不会发生任何事情。然而,位置或高度工作正常,正如预期的那样。有人知道为什么吗?我需要特别的填充物。不管我把键盘avoidingview标签放在哪里,也不管我用它包装什么,它都不会工作 基本上,当我打开键盘时,我试图让向上推。似乎很简单,在上面浪费了一天:( 我还尝试了包含Key
KeyboardAvoidingView
的行为设置为padding
则不会发生任何事情。然而,位置
或高度
工作正常,正如预期的那样。有人知道为什么吗?我需要特别的填充物。不管我把键盘avoidingview
标签放在哪里,也不管我用它包装什么,它都不会工作
基本上,当我打开键盘时,我试图让
向上推。似乎很简单,在上面浪费了一天:(
我还尝试了包含KeyboardawarScrollView
的软件包,运气不好
我目前正在使用
react-native-cli: 2.0.1
react-native: 0.61.2
我的代码:
return (
<KeyboardAvoidingView style={{ flex: 1 }} behavior="position">
<View style={styles.container}>
<ScrollView scrollEnabled={false} contentContainerStyle={styles.textEditorContainer}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<>
<TextInput
autoCorrect={false}
style={styles.title}
placeholder={Strings.screen.edit.titlePlaceholder}
onChangeText={this.onTitleValueChange}
value={titleValue}
/>
{divider}
<RichEditor
ref={this.setEditorRef}
initialContentHTML={this.props.initialEditorValue.content}
style={styles.textEditor}
/>
</>
</TouchableWithoutFeedback>
{this.renderCornerAnimation()}
<View style={styles.toolbarContainer}>
<RichToolbar
style={styles.toolbar}
getEditor={() => this.richText}
iconTint={'#000033'}
selectedIconTint={'#2095F2'}
selectedButtonStyle={{ backgroundColor: 'transparent' }}
/>
</View>
</ScrollView>
</View>
</KeyboardAvoidingView>
);
}
}
interface Style {
container: ViewStyle;
textEditorContainer: ViewStyle;
textEditor: ViewStyle;
title: TextStyle;
toolbarContainer: ViewStyle;
toolbar: ViewStyle;
toolbarButton: TextStyle;
lottieView: ViewStyle;
divider: ViewStyle;
iconSetContainerStyle: ViewStyle;
textInput: ViewStyle;
}
function createStyleSheet(colorScheme: ColorScheme): Style {
return StyleSheet.create<Style>({
container: {
flex: 1,
width: '100%',
height: '100%',
paddingTop: getStatusBarHeight(true),
backgroundColor: color[colorScheme].background,
alignItems: 'center',
},
textEditorContainer: {
width: screenWidth / 1.2,
backgroundColor: palette.white[1],
borderRadius: 40,
},
textEditor: {
borderBottomLeftRadius: 10,
borderBottomRightRadius: 10,
width: '100%',
backgroundColor: palette.white[1],
},
title: {
backgroundColor: palette.white[1],
width: '100%',
padding: 5,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
fontWeight: '700',
fontSize: 20,
},
toolbarContainer: {
flex: 1,
minHeight: 35,
alignItems: 'center',
justifyContent: 'flex-end',
backgroundColor: color[colorScheme].background,
paddingBottom: getBottomSpace(),
},
toolbar: {
height: 35,
backgroundColor: color[colorScheme].background,
},
toolbarButton: {
fontSize: 12,
textAlign: 'center',
},
lottieView: {
position: 'absolute',
top: 0,
right: 0,
width: 20,
height: 20,
},
divider: {
width: '10%',
borderRadius: 4,
marginLeft: 8,
borderBottomWidth: 6,
},
iconSetContainerStyle: {
flexGrow: 1,
justifyContent: 'space-evenly',
alignItems: 'center',
},
textInput: {
color: color[colorScheme].text,
},
});
}
返回(
{除法器}
{this.renderCornerAnimation()}
this.richText}
IContent={'#000033'}
selectedIconTint={'#2095F2'}
selectedButtonStyle={{backgroundColor:'transparent'}
/>
);
}
}
界面风格{
容器:视图样式;
文本编辑器容器:视图样式;
文本编辑器:视图样式;
标题:文本风格;
工具栏容器:视图样式;
工具栏:视图样式;
工具栏按钮:文本样式;
lottieView:视图样式;
分隔器:视图样式;
iconSetContainerStyle:视图样式;
文本输入:视图样式;
}
函数createStyleSheet(colorScheme:colorScheme):样式{
return StyleSheet.create({
容器:{
弹性:1,
宽度:“100%”,
高度:“100%”,
paddingTop:getStatusBarHeight(真),
backgroundColor:color[colorScheme]。背景,
对齐项目:“居中”,
},
textEditorContainer:{
宽度:屏幕宽度/1.2,
背景色:调色板。白色[1],
边界半径:40,
},
文本编辑器:{
边界半径:10,
边界右下角半径:10,
宽度:“100%”,
背景色:调色板。白色[1],
},
标题:{
背景色:调色板。白色[1],
宽度:“100%”,
填充:5,
borderTopLeftRadius:10,
BorderTopRight半径:10,
重量:'700',
尺寸:20,
},
工具栏容器:{
弹性:1,
身高:35,
对齐项目:“居中”,
justifyContent:“柔性端”,
backgroundColor:color[colorScheme]。背景,
paddingBottom:getBottomSpace(),
},
工具栏:{
身高:35,
backgroundColor:color[colorScheme]。背景,
},
工具栏按钮:{
尺寸:12,
textAlign:'中心',
},
乐天视图:{
位置:'绝对',
排名:0,
右:0,,
宽度:20,
身高:20,
},
分隔器:{
宽度:“10%”,
边界半径:4,
边缘左:8,
边界宽度:6,
},
iconSetContainerStyle:{
flexGrow:1,
为内容辩护:“间隔均匀”,
对齐项目:“居中”,
},
文本输入:{
颜色:颜色[colorScheme]。文本,
},
});
}
您是否尝试过将RichToolbar
视图放在滚动视图
之外?@giotskada是的..不起作用。我不明白,位置和高度起作用,但填充不起作用。滚动视图
可滚动吗?如果是,当您一直滚动时,滚动视图
的结尾是否可见?或者键盘是否覆盖了部分?scrollview不可滚动。我知道它不起作用,因为我触发了ctrl+K快捷键,使键盘显示在XCode上,我有时间查看它是否上升。你能尝试将keyboardVerticalOffset
prop设置为不同的值(50、100、200)吗看看会发生什么?你试过把RichToolbar
视图放在ScrollView
之外吗?@giotskada是的..不起作用。我不明白,位置和高度起作用,但填充不起作用。它到底起什么作用呢?ScrollView
是可滚动的吗?如果是的话,当你滚动时,ScrollView
的结尾是否可见一直以来?还是键盘覆盖了部分?scrollview是不可滚动的。我知道它不起作用,因为我触发了ctrl+K快捷键,让键盘显示在XCode上,我有时间看看它是否上升。你能试着将keyboardVerticalOffset
prop设置为不同的值(50、100、200)看看会发生什么吗?