我制作了滚动视图,里面有很多文本字段.我添加了更新的TPKeyBoardAvoidingScrollView并将其添加到滚动视图的文件所有者中.我在.h文件中添加了插座,在.m文件中合成并添加了该行[self.view addSubview:scrollObject];
问题是视图在键盘出现后才开始滚动.加载视图后不会滚动.
对此有何解决方案?
添加这些行并没有解决我的查询
scrollViewObj = [[UIScrollView alloc] init];
self.automaticallyAdjustsScrollViewInsets = NO;
[scrollViewObj setScrollEnabled:YES];
scrollViewObj.maximumZoomScale = 4.0;
scrollViewObj.minimumZoomScale = 0.75;
scrollViewObj.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用带有行为=“padding”的KeyboardAvoidingView。
当我尝试在 TextInput 中输入任何文本时,TextInput 字段不会向上移动。我最后添加了一个正在向上移动的小视图,但它上面的视图。
我还使用带有偏移量的 KeyboardAvoidingView height 属性。它只运行几个组件,例如 2 个 TextInputs。但是当我添加所有组件时,用户界面变得疯狂并且行为混乱。
知道这里发生了什么吗?
这是我关注的教程链接。
render() {
return (
<View style={styles.backgroundContainer}>
<Loader
loading={this.state.isLoading} />
<KeyboardAvoidingView
keyboardVerticalOffset={10}
style={styles.mainContainer}
behavior='padding' >
<View style={styles.formContainer}>
<View style={[styles.centerContainer, { marginTop: 40 }]}>
<Image source={require('./../../Resources/logo.png')} />
<Text style={{ fontWeight: 'bold', color: 'gray', fontSize: 25 }}>AppName</Text>
<Text style={styles.loginMsg}> Login to your Account </Text>
</View>
<View style={styles.inputFieldsContainer}>
<Image style={{ width: 30, height: 30, margin: 5 }} source={require('./../../Resources/logo.png')} />
<TextInput
placeholder='Email'
returnKeyType='next'
keyboardType='email-address'
onChangeText={(value) => this.setState({ userEmail: value })} …Run Code Online (Sandbox Code Playgroud) 我一直在尝试在键盘打开时滚动键盘上方的按钮,我正在使用“react-native-keyboard-aware-scroll-view”,当我将按钮对齐在文本字段下方的顶部时,它会变得很方便,但我希望我的按钮在屏幕底部对齐(弯曲端),在这种情况下键盘覆盖了我的按钮并且按钮不会向上滑动。在 Android 模拟器中它工作正常,但在 iOS 中则不然。我尝试过不同的方法,给予 extraScrollHeight 也不起作用,具有一两个文本字段和更大的屏幕尺寸。请建议一些东西。
这是我的代码。
<SafeAreaContainer>
<KeyboardAwareScrollContainer
showsVerticalScrollIndicator={false}
contentContainerStyle={{ flex: 1 }}>
<FormikContainer>
<Formik
initialValues={{ email: '' }}
onSubmit={values => onSubmitEmail(values)}>
{({ values, errors }) => (
<FormikInternal>
<TextInput
style={styles.input}
onChangeText={ (val) => {console.log(val);}}
value={values.email}
/>
<TextInput
style={styles.input}
onChangeText={ (val) => {console.log(val);}}
value={values.email}
/>
<TextInput
style={styles.input}
onChangeText={ (val) => {console.log(val);}}
value={values.email}
/>
<TextInput
style={styles.input}
onChangeText={ (val) => {console.log(val);}}
value={values.email}
/>
<TextInput
style={styles.input}
onChangeText={ (val) => {console.log(val);}}
value={values.email}
/>
<Button bgColor="red">
<Text fontSize={16} color={theme.color.white}>
{LABELS.Continue}
</Text>
</Button>
</FormikInternal> …Run Code Online (Sandbox Code Playgroud)