How to have fixed header after keyboard is shown on iOS?

爱⌒轻易说出口 提交于 2020-01-16 20:19:59

问题


The fixed header is scrolling after keyboard is open on iOS device. Is there any possibility to have fixed header after keyboard is open? I do not want to have header scrolling with the content.

Here is explained similar problem: https://medium.com/@im_rahul/safari-and-position-fixed-978122be5f29

I am facing the problem in the React project using Cordova.

Thank you very much for your help.


回答1:


use keyboardAvoidingView from 'react-native'
docs

   import {
      KeyboardAvoidingView
    } from 'react-native';

<KeyboardAvoidingView behavior="padding" style={styles.container}>


          <View style={styles.inputContainer}>
            <TextInput
              returnKeyType="next"
              placeholder="Mobile No."
              placeholderTextColor="powderblue"
              keyboardType="number-pad"
              onSubmitEditing={() => this.passwordInput.focus()}
              style={styles.input}
               onChangeText={(value) => this.setState({mobileno:value})}
               value={this.state.mobileno}
            />

            <TextInput
              returnKeyType="go"
              placeholder="Password"
              placeholderTextColor="powderblue"
              style={styles.input}
              secureTextEntry
              ref={input => (this.passwordInput = input)}
               onChangeText={(value) => this.setState({pssd:value})}
               value={this.state.pssd}
            />
          </View>



      </KeyboardAvoidingView>


来源:https://stackoverflow.com/questions/56258034/how-to-have-fixed-header-after-keyboard-is-shown-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!